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

Get rid of sign bit? #44

Closed
oxinabox opened this issue Nov 25, 2019 · 2 comments
Closed

Get rid of sign bit? #44

oxinabox opened this issue Nov 25, 2019 · 2 comments

Comments

@oxinabox
Copy link
Contributor

From here
#42 (comment)

# Numerical value: (-1)^s * c * 10^q
struct Decimal <: AbstractFloat
    s::Bool  # sign can be 0 (+) or 1 (-)
    c::BigInt   # coefficient (significand), must be non-negative
    q::Int  # exponent
end

It doesn't seem to me like s serves any purpose that couldn;t be rolled in c.
Since BigInts can be negative or possitive.

@jmkuhn
Copy link

jmkuhn commented Dec 15, 2020

If you want to be able to distinguish -0.0 from 0.0 keeping sign separate makes sense.

@barucden
Copy link
Collaborator

barucden commented Nov 4, 2024

I also thought that the sign could be moved into the coefficient. However, after re-implementing a few operations, I must say that it is quite convenient that the coefficient is always non-negative and that the sign is a separate field. What John said is also true.

The only advantage I see in removing the field is less memory consumption. But given that this package is not intended for memory-constrained applications (and after all, one bool is negligible compared to the huge BigInts that are commonly expected), I don't think it's relevant. Because of that, I'll take the liberty of closing this issue.

@barucden barucden closed this as completed Nov 4, 2024
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

No branches or pull requests

3 participants