It is currently Wed Jul 24, 2019 10:48 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Rounding to nearest hudred
PostPosted: Thu Jul 11, 2019 8:38 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Jan 20, 2014 6:32 pm
Posts: 237
What would be best way to round to nearest hundred? or does anyone have code already?
Thanks

_________________
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA


Top
 Profile  
Reply with quote  
 Post subject: Re: Rounding to nearest hudred
PostPosted: Thu Jul 11, 2019 9:04 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 866
Code:
a.i = 349
Debug (a+50)/100*100


Code:
a.d = 349
a = Round (a/100, #PB_Round_Nearest) * 100
Debug a

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: Rounding to nearest hudred
PostPosted: Thu Jul 11, 2019 9:36 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Jan 20, 2014 6:32 pm
Posts: 237
Josh wrote:
Code:
a.i = 349
Debug (a+50)/100*100


Code:
a.d = 349
a = Round (a/100, #PB_Round_Nearest) * 100
Debug a


Thanks

_________________
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA


Top
 Profile  
Reply with quote  
 Post subject: Re: Rounding to nearest hudred
PostPosted: Fri Jul 12, 2019 7:24 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 866
Be careful with negative values in the first example. See also here:

https://www.purebasic.fr/english/viewtopic.php?f=4&t=73176

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: Rounding to nearest hudred
PostPosted: Fri Jul 12, 2019 7:49 am 
Offline
User
User

Joined: Mon Jul 17, 2017 7:22 am
Posts: 56
Location: Cotswolds England
How about:
Code:
a = Int(35566*0.01)
Debug a

_________________
If it's falling over......just remember the computer is never wrong!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Fangbeast, Majestic-12 [Bot] and 13 guests


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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye