[READ-ONLY] Mirror of https://github.com/probablykasper/cpc. Text calculator with support for units and conversion cpc.kasper.space
calculator cli conversion converter library math package units units-converter wasm website
0

Configure Feed

Select the types of activity you want to include in your feed.

Fix numbers being possible to raise to the power of units

Kasper (Jun 24, 2026, 8:54 AM +0200) 23c6f8ea f6f771c6

+3 -11
+3
CHANGELOG.md
··· 1 1 # Changelog 2 2 3 + ## Next 4 + - Fix `^` allowing numbers to be raised to the power of units 5 + 3 6 ## 3.1.0 - 2025 Jun 20 4 7 - Add FLOP and FLOPS units 5 8 - Update `fastnum` dependency
-11
src/units.rs
··· 832 832 // x km ^ 3 833 833 let result = (left.value * left.unit.weight()).pow(right.value); 834 834 Ok(to_ideal_unit(Number::new(result, CubicMillimeter))) 835 - } else if lcat == Length && rcat == Length && right.value == d!(1) { 836 - // x km ^ 1 km 837 - Ok(multiply(left, right)?) 838 - } else if lcat == Length && rcat == Length && right.value == d!(2) { 839 - // x km ^ 2 km 840 - let pow2 = multiply(left, Number::new(d!(1), right.unit))?; 841 - let pow3 = multiply(pow2, Number::new(d!(1), right.unit))?; 842 - Ok(pow3) 843 - } else if lcat == Length && rcat == Area && right.value == d!(1) { 844 - // x km ^ km2 845 - Ok(multiply(left, Number::new(d!(1), right.unit))?) 846 835 } else { 847 836 Err(format!("Cannot multiply {:?} and {:?}", left.unit, right.unit)) 848 837 }