Aug-22-2019, 09:37 AM
(Aug-22-2019, 08:27 AM)massimo_m Wrote: Thank you, but in these examples you convert the float in decimal, while i would to have a variable with a arbitrary precision.
my needs are similar to this:
dec_value= myvalue
dec_value.setPrecision(2)
do some stuff
print dec_value.getPrecision()
and it gives me "2"
Hi!
I'm not sure what you mean by arbitrary precision. I thought, according to your original post, that you wanted the totals (for V.A.T. needs) to be shown with 2 digits after the float point (decimal point, or virgula). This is exactly what this little program does (and it rounds the numbers to 2 significant float (decimal) places, it doesn't matter if the number is shorter or longer than that):
So if you introduce 24, the program prints 24.00 €,
if you introduce 24.3, the program prints 24.30 €,
if you introduce 24.35, the program prints 24.35 €,
if you introduce 24.375, the program prints 24.38 €.
newbieAuggie2019
newbieAuggie2019
"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs