Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Truncating a real number
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
omni




PostPosted: Sun May 02, 2004 9:05 am   Post subject: Truncating a real number

How would I truncate all the decimals so then I could just have the whole number.
ex:
1.3->1
1.9->1
2.5->2
2.3->2
23.5->23
Now matter how big the decimal is, I just want the whole number.
Round() doesn't work here. Or would I have to make an algorithm to do it?
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Sun May 02, 2004 9:09 am   Post subject: (No subject)

I think u can use floor. like
code:

put floor (1.3)

simple no?
guruguru




PostPosted: Sun May 02, 2004 10:45 am   Post subject: (No subject)

code:

put floor(2.56)
put 2.56 div 1


Either works. Personal preference.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: