Comments (5)
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.
Regarding hexadecimal, the calculated BigDecimal can be converted to BigInteger, which is then converted to hexadecimal.
from bigdecimal.
@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.
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.
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)
- Do we still want to keep the .NET 5 as an option? HOT 2
- Question: Is there a technical reason that the platform is restricted to x64? HOT 7
- No strong name for .NET Framework targets HOT 5
- SECURITY ISSUE: You are putting your PRIVATE key in the repo HOT 2
- Invalid Parse result of negative number in scientific notation HOT 2
- Parse(Double input) fails , if CurrentCulture has NumberFormat with 'comma' instead of 'dot' HOT 2
- Propose a way to store BigDecimal in SQL tables HOT 3
- Add support for rounding value
- BUG: incorrect parsing with non-dot decimal separator HOT 1
- BUG: converting to double results to 0
- Request: round - add support for negative precision HOT 10
- BUG: Version 2025.1000.0.118 dlls are all versioned 0.0.0.0 HOT 3
- BUG: BigDecimal.GetWholePart doesn't work for cultures that use `,` as a decimal separator HOT 3
- BUG: BigDecimal.Pow(5d, 0.5d) no longer works HOT 6
- BigDecimal.Precision have no effect HOT 8
- Is it possible, that you submit your code to the .NET runtime ? HOT 1
- Nice demo program HOT 1
- Subtraction having issues. HOT 5
- Minor issue: "nu5035" after a Publish. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bigdecimal.