On Tue, Apr 6, 2021 at 11:54 AM sisyphus <sisyphus...@gmail.com> wrote:
> ....

1/10 == 1e1 # True

Aiui this is correct (and to me intuitive) behaviour described here:

https://docs.raku.org/language/numerics#Numeric_infectiousness

So if there's a `Num` (float) in a numeric operation (like `==`) then any
other number that would behave differently if it were coerced to be a
`Num` is coerced to be a `Num` before the operation applies.

So the `e0`, which coerces to a Num, coerces the rational `1.0` to be a
`Num`, and that in turn means the `0.1` (which is, as I would expect, the
exact same as `1/10`) is coerced to a `Num`, and so they compare equal.

----

printf "%.60g\n", 1.0e-1;

Aiui the sprintf in Raku code sucks.

I just did quick search of the three issue queues for "sprintf".
I found several open issues that look closely related (maybe
dupes).

I'll start with one that not only looked to like a bullseye for your
issue but includes what seems to amount to huge and fantastic
patches by Zefram that I suspect have never landed:

https://github.com/Raku/old-issue-tracker/issues/5519

Other issues that might be relevant:
https://github.com/Raku/old-issue-tracker/issues/5013
https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127184
https://github.com/rakudo/rakudo/issues/2187

Perhaps folk who need this to work are using NativeCall and
native numerics with the C library sprintf?

--
raiph

Reply via email to