@mratsim
Hello I adapt Nim-decimal for management, compliant with the AS400. so I test a maximum I introduced the boundary to be in agreement with the database (POSTGRESQL but it is identical with DB2) on the other hand significant numbers are important there are times when we have 20.15 zones in the financial sector see bank (35 digits) during a changeover to € I had only 3cts of difference on the whole accounting.
for the moment my test is stopped at proc fma everything seems OK to me so far in management we do not use math functions the square root of the price of a stock does not mean anything;) etc ... but I will test a lot of more also introduce the calculation of the percentage into a formula
I'm going to put on github the modified project with another name, I do not want there to be a confusion your project is healthy and mine needs to test with a database and for the moment my tests are only on values and interaction with a GUI on the other hand I will report that the base is based on Nim-Decimal
I have found a mistake
my test only works if I do template * * [T: SomeNumber] (a: DecimalType, b: T): untyped = a * newDecimal (b)
Here is one example that works as expected:
let a = newDecimal("1.49")
let b = 1.25
let c1 = a * b
let c2 = b * a
echo c1
echo c2
# 1.8625
# 1.8625
a*10 correct
a*=10 not ok
a =12345678901234567890.12
a*10 echo $a 12345678901234567890.12 ????
a =12345678901234567890.12
a*=10
echo $a 12345678901234567891.2
If I understand you correctly, you are wondering why it doesn't print .2 in the first case? It's because a*10 doesn't change a, it returns a new DecimalType. If you instead run echo a*10 you should get what you expect. If you want to save it you have to assign it to a variable like this: var b = a*10.
a *= 10 on the other hand DOES CHANGE a. That's what "inplace" means.
So the difference between * and *= is that the first one does not change a, but the other do.
Have I understood you correctly? :-)
a= newDecimal("890.12")
a+10 echo $a ... 900.12 a+=10 echo $a ... 910.12 a-10 echo $a ... 900.12 a-=10 echo $a ... 890.12
etc....
import ./decimel/decimal
a= newDecimal("890.12")
a+10
echo $a
a+=10
echo $a
a-10
echo $a
a-=10
echo $a
sorry
import ./decimal/decimal var a= newDecimal("890.12")
a+10 echo $a
a+=10 echo $a
a-10 echo $a
a-=10
echo $a
OK it works sorry a thousand times
I missed a function and I had an overflow yet I have a lot to work with originally "Mike Cowlishaw" in c ++ ..... in my type functions
`+` * (a, b: DecimalType): DecimalType =
var status: uint32
result = newDecimal ()
mpd_qadd (result [], a [], b [], CTX_ADDR, addr status)
personally I did not use it like that I got myself and that's good because I would be more careful
_qadd (a [], a [], b [], CTX_ADDR, addr status)
my error
and me
/// arithmetic operation
Zdcml & Zdcml :: operator ++ (int)
{
ClearBufferDcml ();
_STRING_ = string_format ("% d", 1);
decNumberFromString (T_dcml, (char *) _ STRING_.c_str (), & T_set);
decNumberAdd (_dcml, _dcml, T_dcml, & T_set);
decNumberTrim (_dcml);
return * this;
}
OK it works sorry a thousand times