Reputation: 27
For example, I have vaule "a" = -23 who I want to print as -2.3
I write this code who work good when a > 0, also work in other language string_buf = string.format ( "%1d,%d" ,a //10, math.abs(a) %10)
but when I use only use "//" then I have one more and instead -2.3 see to -3.3
Where is problem?.
Upvotes: -1
Views: 138
Reputation: 27
Ok, I try modf. Works.
a= 0xFF16 -- -234
--16bit register is negative?
if (a & 0x8000 ~=0) then
a= (~a +1) & 0xFFFF
a = -a
end
string_buf = string.format ( "%1d,%d" ,math.modf(a/10), math.abs(a)%10)
Upvotes: 0