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

Handling Overflow #12

Closed
omus opened this issue Jun 16, 2017 · 3 comments · Fixed by #85
Closed

Handling Overflow #12

omus opened this issue Jun 16, 2017 · 3 comments · Fixed by #85

Comments

@omus
Copy link
Contributor

omus commented Jun 16, 2017

Currently a FixedDecimal value can overflow since internally we are using integer math.

julia> import FixedPointDecimals: FD

julia> reinterpret(FD{Int8,2}, typemax(Int8))
FixedDecimal{Int8,2}(1.27)

julia> ans + reinterpret(FD{Int8,2}, 1)
FixedDecimal{Int8,2}(-1.28)

We should include some kind of system, maybe checked_* operations, so that users can choose how overflow is handled. We definitely do not want to ban the overflow behaviour.

@TotalVerb
Copy link
Collaborator

TotalVerb commented Jun 18, 2017

Checked operations sound like a good idea to me, as that's consistent with how Ints work.

Also, there have been proposals in Base to have macros like @checked that rewrite a + b to checked_add(a, b), and so they would tie into any such implemented proposal well.

@DatName
Copy link

DatName commented Jul 19, 2019

Would like to bump this issue. Just stumbled upon

julia>  FixedDecimal{Int64, 12}(1) * 10000000
FixedDecimal{Int64,12}(-8446744.073709551616)

which was unexpected for me.

@NHDaly
Copy link
Member

NHDaly commented Dec 7, 2023

#85

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants