LiamRiddell / obsidian-solve

An unobtrusive Obsidian plugin that quietly processes equations and patterns in real time
MIT License
76 stars 0 forks source link

[Bug] Decimal number calculations only work if the decimal comes first #20

Closed FeralFlora closed 1 year ago

FeralFlora commented 1 year ago

Describe the bug When I try to do any operation on decimal numbers, the output is 0, if the decimal number is not at the start of the line.

To Reproduce Attempt any calculation where a whole number is followed by a decimal number like 0.5.

Expected behavior I would expect , or . to act as decimal points, and that calculations on such decimal numbers would work, regardless of the order of numbers.

Screenshots image

Obsidian

LiamRiddell commented 1 year ago

Thank you for your bug submission @FeralFlora.

Right now, this is currently the "correct" behaviour technically but probably not from the user experience perspective. I will look to improve it. 😄

The reason this happens is because the type of the left operand (459 = Integer) is used as the target type when coercing (converting) the right operand type (0.5 = Float). This means the expression that actually occurred is 459 * 0.

The expression that would work is: 459.0 * 0.5.

I'll keep this bug open as a prompt to improve this functionality. If you wanted to get 50% of the value you could also use the percentage provider:

  1. 50% of 459.0
  2. decrease 459.0 by 50%.
FeralFlora commented 1 year ago

Okay, now I understand the behavior. But yes, from a user perspective, this does not seem very intuitive or convenient. So I look forward to the aforementioned improvements. But thanks for the workarounds / alternatives, those will serve me well in the meantime.

FeralFlora commented 1 year ago

2. decrease 459.0 by 50%.

This is case sensitive. decrease works, but Decrease doesn't.