digitalmars.D.learn - decimal type in d
- vit (6/6) May 15 2022 Hello, I want read decimal type from sql db, do some arithmetic
- IGotD- (11/17) May 16 2022 This also something I wondered, it should be standard in the D
- bauss (4/22) May 16 2022 Here's the implementation if anyone needs it:
- Steven Schveighoffer (3/8) May 16 2022 https://code.dlang.org/search?q=decimal
- vit (8/37) May 17 2022 Thanks, but it is not full implementation of decimal, arithmetic
Hello, I want read decimal type from sql db, do some arithmetic operations inside D program and write it back to DB. Result need to be close to result as if this operations was performed in sql Exists this kind of library ind D? (ideally `pure safe nogc nothrow`).
May 15 2022
On Sunday, 15 May 2022 at 13:26:30 UTC, vit wrote:Hello, I want read decimal type from sql db, do some arithmetic operations inside D program and write it back to DB. Result need to be close to result as if this operations was performed Exists this kind of library ind D? (ideally `pure safe nogc nothrow`).This also something I wondered, it should be standard in the D library. Implementing it can be done straight forward with existing D language primitives, essentially a struct. value but the exponent is a power of 10 (internally total 16 bytes). This means that for "simple" mathematics rational decimal values remains rational decimals values and not some rounded value that would happen if you would use normal floating point values. The decimal type is essential for financial calculations.
May 16 2022
On Monday, 16 May 2022 at 09:46:57 UTC, IGotD- wrote:On Sunday, 15 May 2022 at 13:26:30 UTC, vit wrote:Here's the implementation if anyone needs it: https://referencesource.microsoft.com/#mscorlib/system/decimal.cs,1b2858baf311cbf9 Should be fairly straightforward to implement.Hello, I want read decimal type from sql db, do some arithmetic operations inside D program and write it back to DB. Result need to be close to result as if this operations Exists this kind of library ind D? (ideally `pure safe nogc nothrow`).This also something I wondered, it should be standard in the D library. Implementing it can be done straight forward with existing D language primitives, essentially a struct. point value but the exponent is a power of 10 (internally total 16 bytes). This means that for "simple" mathematics rational decimal values remains rational decimals values and not some rounded value that would happen if you would use normal floating point values. The decimal type is essential for financial calculations.
May 16 2022
On 5/15/22 9:26 AM, vit wrote:Hello, I want read decimal type from sql db, do some arithmetic operations inside D program and write it back to DB. Result need to be close to result as if this operations was performed in sql DB. Something Exists this kind of library ind D? (ideally `pure safe nogc nothrow`).https://code.dlang.org/search?q=decimal -Steve
May 16 2022
On Monday, 16 May 2022 at 09:59:41 UTC, bauss wrote:On Monday, 16 May 2022 at 09:46:57 UTC, IGotD- wrote:Thanks, but it is not full implementation of decimal, arithmetic operator are missing. On Monday, 16 May 2022 at 16:41:33 UTC, Steven Schveighoffer wrote:On Sunday, 15 May 2022 at 13:26:30 UTC, vit wrote:Here's the implementation if anyone needs it: https://referencesource.microsoft.com/#mscorlib/system/decimal.cs,1b2858baf311cbf9 Should be fairly straightforward to implement.[...]This also something I wondered, it should be standard in the D library. Implementing it can be done straight forward with existing D language primitives, essentially a struct. point value but the exponent is a power of 10 (internally total 16 bytes). This means that for "simple" mathematics rational decimal values remains rational decimals values and not some rounded value that would happen if you would use normal floating point values. The decimal type is essential for financial calculations.On 5/15/22 9:26 AM, vit wrote:Thanks, most of the packages are incomplete or too old (doesn't compile), but this one https://code.dlang.org/packages/decimal can by modified to work for my use.Hello, I want read decimal type from sql db, do some arithmetic operations inside D program and write it back to DB. Result need to be close to result as if this operations Exists this kind of library ind D? (ideally `pure safe nogc nothrow`).https://code.dlang.org/search?q=decimal -Steve
May 17 2022