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?.
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.