Page 1 of 1
Posted: Fri Apr 18, 2003 1:25 pm
by BackupUser
Restored from previous forum. Originally posted by Froggerprogger.
I'm really missing one more type of rounding.
Not only ALWAYS upwards or ALWAYS downwards, but ALWAYS mathematical correct. So if the value is above or exactly value.5 then round upwards, else downwards.
And even more cool would be a third parameter to define the after-comma-position to round to.
So round(12.3665, 2, 3) would return 12.367 (true rounding, 3rd after-comma-position)
Purebasic - what a nice name for a girl-friend
Posted: Fri Apr 18, 2003 8:32 pm
by BackupUser
Restored from previous forum. Originally posted by Thomas.
and how about rounding the pre comma values
round(125.567, 3, 1) would give 100
round(125.567, 4, 2) would give 130
PureBasic is different...
Posted: Sat Apr 19, 2003 3:20 am
by BackupUser
Restored from previous forum. Originally posted by wayne1.
I'm really missing one more type of rounding.
Not only ALWAYS upwards or ALWAYS downwards, but ALWAYS mathematical correct. So if the value is above or exactly value.5 then round upwards, else downwards.
Here's some QB code to convert to purebasic in the meantime.
Code: Select all
'===========================================================================' Subject: ROUND NUMBERS Date: 09-03-97 (20:59)
' Author: Kinslayer Indst. (Cody Bunch) Code: QB, QBasic, PDS
' Origin: [url]mailto:jbunch@bellsouth.net">jbunch@bellsouth.net Packet: ALGOR.ABC
'===========================================================================
Cls
Color 5
Print " THIS PROGRAM WILL ROUND NUMBERS TO SPECIFIED DECIMAL PLACES "
Print " FEEL FREE TO USE THIS PROGRAM AT YOUR OWN FREE WILL AND PUT"
Print " IT ON YOUR OWN PAGE AT MY CONSENT THE E-MAIL ADRESS WILL BE"
Print " DISPLAYED AT THE END OF THE PROGRAM. IF YOU HAVE ANY INTERESTS IN"
Print " ANY OTHER MATH PROGRAMS LET ME KNOW AND I'LL SEE WHAT I CAN DO"
Print " NOTE: CAPS LOCK MUST BE ON TO ROUND MORE THAN 1 NUMBER"
MORE$ = "Y"
While MORE$ = "Y"
INPUT "NUMBER TO BE ROUNDED"; A
INPUT "NUMBER OF PLACES"; B
X = Int(A * 10 ^ B + 0.5) / 10 ^ B
Print A; "ROUNDED TO"; B; "PLACES_"; X
Print
INPUT "DO ANOTHER (Y/N)"; MORE$
Wend
Color 3
Print "THIS PROGRAM WAS MADE BY KINSLAYER INDST."
Print "PLEASE E-MAIL ANY COMMENTS TO [url]mailto:JBUNCH@BELLSOUTH.NET[/url]"
Print "THANK YOU"
taken from
Posted: Wed Apr 23, 2003 2:29 am
by BackupUser
Restored from previous forum. Originally posted by wayne1.
Code: Select all
;I found out it doesn't work correctly always because purebasic does not have doubles;so below returns 22.934 instead of 22.935 guess we'll have to wait for doubles
A.f = 22.9354 ;number to round
B.w=3 ;decimal place to round to
X.f = Int(A * Pow(10, B) + 0.5) / Pow(10, B)
MessageRequester("",StrF(X,B),0)