Is there any implementation in phobos of something similar to BigInt but for nonintegers as well? If there isn't is there a dub package that does this, and if so, which one?
Thread overview  


August 04 Arbitrary precision decimal numbers  

 
August 05 Re: Arbitrary precision decimal numbers  

 
Posted in reply to Ruby The Roobster  On Thursday, 4 August 2022 at 13:01:30 UTC, Ruby The Roobster wrote: >Is there any implementation in phobos of something similar to BigInt but for nonintegers as well? If there isn't is there a dub package that does this, and if so, which one? We have this: https://code.dlang.org/search?q=decimal I end up using BigInt instead on a custom wrapper that stores the precision hint. To calculate with any number, it need to convert each value to the same base (eg. storing 10.234 simply results in a BigInt with value 10234 and the precision hint of 3) and then forward the operation to BigInt. 
August 05 Re: Arbitrary precision decimal numbers  

 
Posted in reply to frame  On Friday, 5 August 2022 at 14:00:32 UTC, frame wrote: >On Thursday, 4 August 2022 at 13:01:30 UTC, Ruby The Roobster wrote: >Is there any implementation in phobos of something similar to BigInt but for nonintegers as well? If there isn't is there a dub package that does this, and if so, which one? We have this: https://code.dlang.org/search?q=decimal I end up using BigInt instead on a custom wrapper that stores the precision hint. To calculate with any number, it need to convert each value to the same base (eg. storing 10.234 simply results in a BigInt with value 10234 and the precision hint of 3) and then forward the operation to BigInt. I'm already trying to make one, and I have a similar idea, but I ewant it extended to complex numbers. Also, what about division and exponentiation. You can't just forward them to BigInt and get a good result, BigInt will just round to an integer for these two. 
August 05 Re: Arbitrary precision decimal numbers  

 
Posted in reply to Ruby The Roobster  On Friday, 5 August 2022 at 14:03:36 UTC, Ruby The Roobster wrote: >Also, what about division and exponentiation. You can't just forward them to BigInt and get a good result, BigInt will just round to an integer for these two. There are divMod() and powmod() for BigInt but I have no idea how precise they really are. 
August 05 Re: Arbitrary precision decimal numbers  

 
Posted in reply to frame  On Friday, 5 August 2022 at 14:11:10 UTC, frame wrote: >On Friday, 5 August 2022 at 14:03:36 UTC, Ruby The Roobster wrote: >Also, what about division and exponentiation. You can't just forward them to BigInt and get a good result, BigInt will just round to an integer for these two. There are divMod() and powmod() for BigInt but I have no idea how precise they really are. I'm currently working on an arbitrarily precise division algortihm based off of the donebyhand standard algorithm, but I need to get it to work for complex numbers, which it's just not. 
August 06 Re: Arbitrary precision decimal numbers  

 
Posted in reply to Ruby The Roobster  On Friday, 5 August 2022 at 14:25:39 UTC, Ruby The Roobster wrote: >I'm currently working on an arbitrarily precise division algortihm based off of the donebyhand standard algorithm, but I need to get it to work for complex numbers, which it's just not. I once did a completely inline implementation of xlcmplx based on an arbitrary precision float (in this context called xlfloat) in C++.
You can also get the implementation of xlfloat, if you like  but that one is NOT completely inline and much longer :D 
August 06 Re: Arbitrary precision decimal numbers  

 
Posted in reply to Dom Disc  On Saturday, 6 August 2022 at 11:25:28 UTC, Dom Disc wrote: >I once did a completely inline implementation of xlcmplx Sorry, one function is NOT inline: >
But you should forget about that, because D has much better methods to create a string. In fact good enough that also this function could have been inline... but in D the whole concept of headers is superfluous, so who cares. 
August 06 Re: Arbitrary precision decimal numbers  

 
Posted in reply to Ruby The Roobster  On Thursday, 4 August 2022 at 13:01:30 UTC, Ruby The Roobster wrote: >Is there any implementation in phobos of something similar to BigInt but for nonintegers as well? If there isn't is there a dub package that does this, and if so, which one? Also you could find usefull such projects: 
August 10 Re: Arbitrary precision decimal numbers  

 
Posted in reply to Sergey  On Saturday, 6 August 2022 at 13:20:19 UTC, Sergey wrote: >On Thursday, 4 August 2022 at 13:01:30 UTC, Ruby The Roobster wrote: >Is there any implementation in phobos of something similar to BigInt but for nonintegers as well? If there isn't is there a dub package that does this, and if so, which one? Also you could find usefull such projects: It doesn't provide for arithmetic operations though, according to the docs. 
August 11 Re: Arbitrary precision decimal numbers  

 
Posted in reply to Ruby The Roobster  On Wednesday, 10 August 2022 at 14:11:04 UTC, Ruby The Roobster wrote: >On Saturday, 6 August 2022 at 13:20:19 UTC, Sergey wrote: >On Thursday, 4 August 2022 at 13:01:30 UTC, Ruby The Roobster wrote: >Is there any implementation in phobos of something similar to BigInt but for nonintegers as well? If there isn't is there a dub package that does this, and if so, which one? Also you could find usefull such projects: It doesn't provide for arithmetic operations though, according to the docs. Maybe you'll have better luck with this? 