bbodi / notecalc3

NoteCalc is a handy calculator trying to bring the advantages of Soulver to the web.
https://bbodi.github.io/notecalc3/
GNU Affero General Public License v3.0
1.16k stars 43 forks source link

Units dropped in calculation #2

Closed zacps closed 3 years ago

zacps commented 3 years ago

First of all, super cool tool; I can see myself using this a lot.

In the following calculation the last result has no unit, when it should have the unit mol:

halflife = 1.5 years
decayconst = ln(2)/halflife
n0 = 1 mol
n0*e^(decayconst*(100 years))
zacps commented 3 years ago

Another unit note, it would be great if it autodetected the appropriate prefix, for example:

1 fm // 1*10^-15 m
1*10^15 // returns 1 000 000 000 000 000 fm instead of 1 m
abhijit-hota commented 3 years ago

Are constants like e and pi defined in NoteCalc? Both exp(2) and e^2 return 2.

Edit: If I'm looking at the right file, they're not?

bbodi commented 3 years ago

pi is defined, type .pi and press tab or simply use the pi() function.

e is not defined yet. ( The downvote is because this qustion is totally irrelevant for this issue)

abhijit-hota commented 3 years ago

pi is defined, type .pi and press tab or simply use the pi() function.

Ah, I see. Thanks!

( The downvote is because this qustion is totally irrelevant for this issue)

Well, I asked that because the author of the issue uses e in this line: n0*e^(decayconst*(100 years))

...and I thought maybe e not being defined is a reason.

bbodi commented 3 years ago

Oh I see, you are right, sorry then!

bbodi commented 3 years ago

I close this issue:

It is not obvious when the user wants to see the result in the exact unit as the input, or when it is preferable to have a more user-friendly output, so currently the user has to specify it explicitly.

Later there might be a global option for controlling it in the whole note..

zacps commented 3 years ago

To be clear the second part was not asking for unit conversions, just for SI prefixes to be used automatically, i.e. if the unit was already meters (as above) and the associated value was outside of the range [0,1000) then the appropriate SI prefix would be added.


Edit: My mistake about e and ln not being defined, I'd like to see those added as they are both extremely common.

bbodi commented 3 years ago

First of all, super cool tool; I can see myself using this a lot.

In the following calculation the last result has no unit, when it should have the unit mol:

halflife = 1.5 years
decayconst = ln(2)/halflife
n0 = 1 mol
n0*e^(decayconst*(100 years))

I am not sure if this is the expected result, but in the latest version (0.3.0, will be released tomorrow), this works

halflife = 1.5 years           █                          1.5                              year
decayconst = ln(2)/halflife    █                          0.4620981203732966666663863889 / year
n0 = 1 mol                     █                          1                                 mol
n0*e()^(decayconst*100 years)  █ 94 961 194 206 024 488 745.13364918                        mol