Coder Social home page Coder Social logo

Comments (5)

qq1176914912 avatar qq1176914912 commented on August 28, 2024 1

BigInteger

My idea at that time was to input the hexadecimal string directly to compute and output the hexadecimal result, and then I thought that I could convert to BigInteger and then convert to hexadecimal.

from bigdecimal.

qq1176914912 avatar qq1176914912 commented on August 28, 2024

Regarding hexadecimal, the calculated BigDecimal can be converted to BigInteger, which is then converted to hexadecimal.

from bigdecimal.

Protiguous avatar Protiguous commented on August 28, 2024

@qq1176914912, Were you asking if it is possible to use two strings in an operation like BigDecimal.Multiply(x,y)?
Where x and y are both hexadecimal strings?
And/or the resulting BigDecimal can also be shown as a hexadecimal string?

from bigdecimal.

AdamWhiteHat avatar AdamWhiteHat commented on August 28, 2024

BigDecimal can be converted to BigInteger, which is then converted to hexadecimal.

Yeah, but then you are losing the decimal part.

No it doesn't support hexadecimal representation yet, but just like how Int32 and other numeric types support a "X" or "Xn" format specifier, I think we should too (Note: In "Xn", the n specifies the minimum number of digits desired, e.g."X2" or "X8").
See Microsoft - Hexadecimal format specifier for the specifics.

Note here that as far as format specifier strings go, all numeric types support the Binary ("B"), Currency ("C"") and Exponential (scientific) ("E") formats too. I think we already support the exponential specifier. Should we also support the Binary and Currency too? Currency is simple. Binary would be the same level of effort as the hexadecimal. Actually, we might as well support arbitrary base at that point. Write it once for arbitrary base. Funnily enough, this could all be done by easily by taking a dependency on my Polynomial library, but we wont do that. But the code there does show an example of how it could be done.

Implementation note: Microsoft says that the max value it supports for the precision identifier is Int32.MaxValue (or 999,999,999 for .NET 7, which is smaller for some reason). While it's probably not necessary to support beyond Int32.MaxValue, if our whole schtick is arbitrary precision, we might as well parse the precision identifier as a BigInteger and give the user enough rope to hang themselves, or give them the ammo they want for their foot-gun, or substitute in your own silly idiom here if needed.

This would be a useful feature. Not sure how much it would be used though.

Note to contributors who watch this library: I'm not asking anyone else to develop this, I don't mind. I've already written this type of code before.

QUESTION: If we support arbitrary base, how should that be specified? ToString("BaseN"), where N is a number?

from bigdecimal.

qq1176914912 avatar qq1176914912 commented on August 28, 2024

BigDecimal can be converted to BigInteger, which is then converted to hexadecimal.

Yeah, but then you are losing the decimal part.

No it doesn't support hexadecimal representation yet, but just like how Int32 and other numeric types support a "X" or "Xn" format specifier, I think we should too (Note: In "Xn", the n specifies the minimum number of digits desired, e.g."X2" or "X8"). See Microsoft - Hexadecimal format specifier for the specifics.

Note here that as far as format specifier strings go, all numeric types support the Binary ("B"), Currency ("C"") and Exponential (scientific) ("E") formats too. I think we already support the exponential specifier. Should we also support the Binary and Currency too? Currency is simple. Binary would be the same level of effort as the hexadecimal. Actually, we might as well support arbitrary base at that point. Write it once for arbitrary base. Funnily enough, this could all be done by easily by taking a dependency on my Polynomial library, but we wont do that. But the code there does show an example of how it could be done.

Implementation note: Microsoft says that the max value it supports for the precision identifier is Int32.MaxValue (or 999,999,999 for .NET 7, which is smaller for some reason). While it's probably not necessary to support beyond Int32.MaxValue, if our whole schtick is arbitrary precision, we might as well parse the precision identifier as a BigInteger and give the user enough rope to hang themselves, or give them the ammo they want for their foot-gun, or substitute in your own silly idiom here if needed.

This would be a useful feature. Not sure how much it would be used though.

Note to contributors who watch this library: I'm not asking anyone else to develop this, I don't mind. I've already written this type of code before.

QUESTION: If we support arbitrary base, how should that be specified? ToString("BaseN"), where N is a number?

Thank you for taking the time to reply. I think your idea is very good and can be easily understood by using "ToString("BaseN").

from bigdecimal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.