Help with String formatting... Only show 2 decimal places...

So I am trying to get it so that I only have two decimal places, BUT, I don’t want to round it. So a number like:
-.432568
would be -.43

Anyone have any pointers? Every LUA function I’ve found actually rounds it, which doesn’t work for what I’m trying to do.
Thanks,
Scott.

[import]uid: 19193 topic_id: 19049 reply_id: 319049[/import]

Hey Scott,

I THINK this will work…

local yourNumber = 3.7685344  
yourNumber = math.floor(yourNumber\*100)/100  

The idea being:
Multiply your number by 100 to shift the decimal point to the right 2 places.
Use floor to cleave off everything after the decimal point.
Divide your number by 100 to shift the decimal point to the left 2 places.

Now, your number is negative so you would have to use -100:

local yourNumber = -.432568  
yourNumber = math.floor(yourNumber\*-100)/-100  

I realize it is not the most robust solution but it should work. Ideally there would be some some of precision function that truncates but doesn’t round anything. [import]uid: 8444 topic_id: 19049 reply_id: 73458[/import]

See string.format here:
http://www.lua.org/pil/20.html

foo = string.format("%.2f", -.432568)
[import]uid: 7563 topic_id: 19049 reply_id: 73460[/import]