New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ml and cc^3 are not being simplified #76
Comments
Doesn't the unit "ml" mean "milli-liter" (volume)? And "cm" mean "centi-meter" (length)? Duh... Never-mind... "cm^3" (volume), not "cm" (length). |
Ok, I see what you're doing here. The issue is just that things aren't simplified in the text representation, since the "g/cm^3" is not compatible with "ml". If you instead did:
...it would simplify? |
Thanks for that explanation. So we should just cast the units manually rather relying on automatic simplification... So are units (or prefixes) ever simplified automatically? Do you think this would work? // same setup as before...
var w = Qty('1 g');
var v = Qty('1 cm^3');
var density = w.div(v);
var sample_v = Qty('100 ml');
var sample_w = sample_v.mul(density);
sample_w.toString() // returns '100 ml*g/cm^3'
// would this work?
sample_w.toString('g') // expect to return '100 g'? I'll try this next time I work with on this part of my project. |
or maybe (if you already know you are looking at a result in units of "g"):
,,,but yes, it looks like he added the option for target units in the toString function, so ignore my above. |
So Qty does properly simplify/convert between 'ml' and 'cm^3'.
|
js-quantities doesn't simplify
ml
andcm^3
corrently when doing math.js-quantities does recognize
ml
andcm^3
as the same unit however...The text was updated successfully, but these errors were encountered: