arturo icon indicating copy to clipboard operation
arturo copied to clipboard

How to handle `/` and `//` for Quantity values?

Open drkameleon opened this issue 1 year ago • 1 comments

Generally, Arturo has 2 different division operators: / (div) and //(fdiv), the former corresponding to integer division and tha latter to floating-point division.

That means that if you divide e.g. 5 with 2, the result depends on which operator you use:

5 / 2 ; this will return the integer division result: 2

5 // 2 ; this will return the "normal" result: 2.5

Now, this is how it works with Integer values.

When we do the same with floating-pointing numbers (see: :floating), the 2 operators behave in an identical way, given that the nature of the numbers themselves is a floating-point number.

Now, Quantity values are, by-design, based on Rational values. And the reason is precision, among others.

How should we handle the 2 operators for Quantity values?

E.g.


5`N / 2 ; should this return 2.5`N (or 5:2`N), or should it be 2`N (or 4:2`N)

drkameleon avatar Jan 12 '24 08:01 drkameleon

Also see: https://github.com/arturo-lang/arturo/issues/1203

drkameleon avatar Jan 12 '24 15:01 drkameleon