Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rationals Overflow Error on 32-bit machine #4194

Closed
Vladar4 opened this issue May 20, 2016 · 2 comments
Closed

Rationals Overflow Error on 32-bit machine #4194

Vladar4 opened this issue May 20, 2016 · 2 comments
Labels

Comments

@Vladar4
Copy link
Contributor

@Vladar4 Vladar4 commented May 20, 2016

import rationals

echo toRational(5.24, high(int16))
echo toRational(5.24, high(int32))

Output on 64-bit machine:

131/25
131/25

Output on 32-bit machine:

131/25
Traceback (most recent call last)
ratio.nim(4)             ratio
rationals.nim(92)        toRational
rationals.nim(49)        toRationalSub
system.nim(2532)         sysFatal
Error: unhandled exception: over- or underflow [OverflowError]
nim -v
Nim Compiler Version 0.13.1 (2016-05-20) [Linux: amd64]
Copyright (c) 2006-2016 by Andreas Rumpf

git hash: 268f25225abab72e197274c31ebfee7ab6dbe0d4
active boot switches: -d:release
nim -v
Nim Compiler Version 0.13.1 (2016-05-20) [Windows: i386]
Copyright (c) 2006-2016 by Andreas Rumpf

active boot switches: -d:release
@Araq

This comment has been minimized.

Copy link
Member

@Araq Araq commented May 22, 2016

@def- ping.

@Araq Araq added the Stdlib label May 22, 2016
@def-

This comment has been minimized.

Copy link
Member

@def- def- commented May 22, 2016

I didn't write that toRational I believe. It looks pretty slow to me btw, 0.4 s on my system for toRational(5.24, high(int32)), no idea if better algorithms exist.

@dom96 dom96 closed this in 834ad57 May 23, 2016
dom96 added a commit that referenced this issue May 23, 2016
Fix toRational overflow by calculating internally with int64s (fixes #4194)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.