Hey
i am having a doulbe number like 14.25, which gets math.ceil()ed and it is 15.0
The ".0" after the 15 does get printed now, which i dont want.
How get i rid of this?
Sincerly
unobtanium
Annoying double number
Started by unobtanium, Jul 02 2013 05:53 PM
4 replies to this topic
#1
Posted 02 July 2013 - 05:53 PM
#2
Posted 02 July 2013 - 06:43 PM
I just typed print(math.ceil(14.25)) in the Lua interpreter and 15 was printed. What context does this happen in?
#3
Posted 02 July 2013 - 06:55 PM
Try using a format string.
Or,
They both do the same thing, just with slightly different syntax.
print(string.format('%d', someNumber))
Or,
print(('%d'):format(someNumber))
They both do the same thing, just with slightly different syntax.
#5
Posted 02 July 2013 - 07:56 PM
theoriginalbit, on 02 July 2013 - 07:24 PM, said:
Nope, "%d" is for integers too. "%f", "%e" and "%g" are for float/double.
This printf reference lists all the formats you can use. string.format uses printf (in the C version), so this should be the same for CC lua.
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











