Open ch-47 opened 1 year ago
If you write 1.0/4 or 1/4.0 or 1.0/4.0, then the result will be float. It's inspired by Rust's syntax.
On Sun, Apr 23, 2023 at 9:37 PM ch-47 @.***> wrote:
Is there a way to convert numbers before evaluation? For example, fractions like 1/4 and 1/3 are evaluated to 0 and 0. Which makes sense, but it would be nice to get 0.25 and 0.33 instead.
— Reply to this email directly, view it on GitHub https://github.com/ISibboI/evalexpr/issues/125, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASATXV3GLTIBG5EOPP7UOTXCVZHVANCNFSM6AAAAAAXIWIGPQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Yes, I understand that. I should have specified that I'm using eval_number
function, so I was thinking maybe there is a way to do that implicitly. And I was talking about fractions in general, not the division operation. Sorry, if it doesn't make sense.
eval_number just means that the result of the expression will be converted to a float. It does not affect evaluation itself. Supporting fractions could be done by making the integer and float types generic. There is #111, and some branch where I have experimented with that. I am happy to accept pull requests into that direction.
On Mon, 24 Apr 2023, 18.10 ch-47, @.***> wrote:
Yes, I understand that. I should have specified that I'm using eval_number function, so I was thinking maybe there is a way to do that implicitly. And I was talking about fractions in general, not the division operation. Sorry, if it doesn't make sense.
— Reply to this email directly, view it on GitHub https://github.com/ISibboI/evalexpr/issues/125#issuecomment-1520363545, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASATXTEYTARKMUAHN3HA5LXC2JWTANCNFSM6AAAAAAXIWIGPQ . You are receiving this because you commented.Message ID: @.***>
Is there a way to convert numbers before evaluation? For example, fractions like
1/4
and1/3
are evaluated to0
and0
. Which makes sense, but it would be nice to get0.25
and0.33
instead.