Need Help With Printing Large Numbers

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
JetSpike
Posts: 8
Joined: Mon Sep 19, 2005 2:38 am

Need Help With Printing Large Numbers

Post by JetSpike »

Here is what happens:

x = 123456
print(x)
------------
1.2346+e05


Here is what I want:
x = 123456
print(x)
-------------
123456


Can anyone help me achieve this?
JetSpike
Posts: 8
Joined: Mon Sep 19, 2005 2:38 am

Post by JetSpike »

Nevermind, I came up with a hack to get the job done, it anyone is interested here is the code I am using:

if intTotalScore >= 100000 then
iScore = tostring(math.floor(intTotalScore/100000)) .. tostring(intTotalScore - (math.floor(intTotalScore/100000))*100000)
fScore:print(300,250,iScore)
else
fScore:print(300,250,intTotalScore)
end
fullerlee
Posts: 54
Joined: Thu Nov 03, 2005 9:46 am

Post by fullerlee »

You could use:

Code: Select all

string.format("%8.0f", x)
Where 8 is the number of chars to allocate before the dp and 0 is the number after (i.e. print a whole number).

Lee
Post Reply