gentooboontoo / js-quantities

JavaScript library for quantity calculation and unit conversion
http://gentooboontoo.github.io/js-quantities/
MIT License
396 stars 103 forks source link

The base scalar of 'sqft' is incorrect #146

Closed greatbullfrog closed 6 months ago

greatbullfrog commented 6 months ago

The base scalar of 'sqft' is 1 which I think it should be 0.3048*0.3048, and the following code returns '1 sqft': new Qty(1, 'm2').to('sqft').format()

glepretre commented 6 months ago

base stands for SI unit. And the SI unit of area is the square meter. So the base scalar of any area is 1 square meter.

greatbullfrog commented 6 months ago

well... I didn't quite get it. I thought 'sqft' means "squre feet" and 1 m^2 should be 10.7639104 sqft, while "new Qty(1, 'm2').to('sqft').format()" doesn't give me the expected output. besides it seems "new Qty(1, 'm2').to('ft2').format()" works well

glepretre commented 6 months ago

My bad, you're right. There seems to be a bug :bug:

> new Qty ("1m2").to("sqft")
Qty {
  scalar: 1,
  baseScalar: 1,
  signature: 2,
  _conversionCache: {},
  numerator: [ '<sqft>' ],
  denominator: [ '<1>' ],
  initValue: { scalar: 1, numerator: [ '<sqft>' ], denominator: [ '<1>' ] },
  _isBase: false,
  _units: 'sqft'
}

The baseScalar should be 1 but not the scalar