I want to convert a float value to round down 5 factor value, this means for example 0.05,0.10,0.15
.
Suppose I have a value like 9.48
, and I want to convert it into 9.45
.
I tried with this:
val = 9.48
val - val % 0.05
It returns 9.450000000000001
. That is good for me but the problem is when I have 9.60
, it converts asn to 9.55
.
When the value is in already factor of 5 then it stays as it is.