forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need Help With Printing Large Numbers

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
JetSpike



Joined: 19 Sep 2005
Posts: 8

PostPosted: Tue Jan 17, 2006 10:18 am    Post subject: Need Help With Printing Large Numbers Reply with quote

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?
Back to top
View user's profile Send private message
JetSpike



Joined: 19 Sep 2005
Posts: 8

PostPosted: Tue Jan 17, 2006 11:32 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
fullerlee



Joined: 03 Nov 2005
Posts: 54

PostPosted: Wed Jan 18, 2006 5:38 am    Post subject: Reply with quote

You could use:

Code:
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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group