gtg922r / obsidian-numerals

An obsidian plugin which turns a math code block into a full featured calculator
Other
391 stars 8 forks source link

Help needed: How to specify the number of decimals in the output? #28

Closed ballastcanary closed 1 year ago

ballastcanary commented 1 year ago

It defaults to 3 decimals. I've tried using the math.round(x,n) function from mathjs but it gives an error. Eg. roundoff = math.round(3.22,1) will not calculate.

gtg922r commented 1 year ago

You don't need to specify math., so just do as follows:

roundoff = round(3.22,1)

Note that this is actually rounding the number not just changing the rendered output, so roundoff will now contain 3.2.

If you are looking for the ability to specify the output number format (including how many decimals) on a per-line (or whole vault) basis, perhaps you could open a new feature request for that with some example use cases.

Closing as fixed, but please re-open if I haven't addressed your issue

RobertoHRO commented 1 year ago

This input: grafik produces this output: grafik

in Numeral beta 1.09.

So from my point there are issues with the underlying mathjs (round(100*pi,-1) should give 310 from my point of view) and with the rendering in math-tex, but if yiu ommit the 'math.' it should work.

DaveHenning commented 1 month ago

Can this be used with a variable?

salary_annual = $150000
salary_weekly = salary_annual / 52
round(salary_weekly,1)

Doesn't work for me.