for example, i want to get a float with the initial 3 digits from e (2.71 from 2.718281828...), is there any function i can use ? i have tried round(), math.floor() and Decimal(1).exp() with getcontext().prec=1, but none of them gives me what i want (round() gives me 2.72, math.floor() 2 and Decimal(1).exp also 2.72) i dont want to round up the float.
thanks in advance.
round(x - 0.005, 2)
# => 2.71
math.floor(x * 100) / 100
# => 2.71
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With