I need to truncate to 1 decimal place, not to the whole number. It appears that round, ceil, and floor all go to the appropriate whole number.
I need 2.768 to be formatted as 2.7
When I use
format(2.768, "-#0.0")
I get 2.8.
I saw a thread about this subject, but the OP wanted to round to the nearest neg whole number.
Help appreciated
[code] dim v as double = -555555555.99999
dim r As Double
dim i As Int64
dim c As Currency
If v<0 Then // nearest double with 1 decimal
r = Ceil(v * 10) / 10
Else
r = Floor(v * 10) / 10
End
// r = -555555555.8999999761581421 — nearest double 55555555.9 achievable from the original
break
r = ((v * 10)\1)/10 // Tricking with implicit integer conversion
// r = -214748364,800000011920929 — Maybe it becomes completely broken
break
i=(v*10) // add 1 decimal and truncate as Int64
c=i/10 // move the decimal point to the correct place -555555555.9 As Currency
r=c // If you move it to a double, it becomes -555555555.8999999761581421 again
break[/code]