|
-
Jul 30th, 2000, 12:04 PM
#1
Thread Starter
Frenzied Member
I'm making this money balncing thing, now if the number that the user enters, and devides by 4, lets say that a number that has 3 digits after the . (decimal) how do I make it round it? to the last 2 decimals?
NXSupport - Your one-stop source for computer help
-
Jul 30th, 2000, 12:13 PM
#2
If you have VB6, use the Round function.
Code:
MyNum = Round(MyNum, 2)
-
Jul 30th, 2000, 12:31 PM
#3
Thread Starter
Frenzied Member
NXSupport - Your one-stop source for computer help
-
Jul 30th, 2000, 12:33 PM
#4
Thread Starter
Frenzied Member
also, how do I make it round down?
NXSupport - Your one-stop source for computer help
-
Jul 30th, 2000, 12:40 PM
#5
I believe you would need to extract the 2nd and 3rd numbers after the decimal and write your own code to round down or up as you see fit. If you always want it rounded down, just delete everything after the second decimal place. Hope that makes sense.
-
Jul 30th, 2000, 12:42 PM
#6
To round a number, use the Int function.
-
Jul 30th, 2000, 12:44 PM
#7
Thread Starter
Frenzied Member
I'm not sure that I understand hellswraith, and, is there a way to round the number down the way megratron told me:
mynum = Round(mynum, 2)
is there a code like that that will always round down?
NXSupport - Your one-stop source for computer help
-
Jul 30th, 2000, 01:22 PM
#8
Frenzied Member
the Int and Fix Functions always round down. I don't know one that always rounds down to a number of decimal places but you can make your own
Code:
Private Function RoundDown(ByVal Number As Double, ByVal DP As Integer)
RoundDown = Int(Number * (10 ^ DP)) / (10 ^ DP)
End Function
-
Jul 30th, 2000, 01:31 PM
#9
I don't know one that always rounds down to a number of decimal places
The Round function does this.
-
Jul 30th, 2000, 01:38 PM
#10
Frenzied Member
that rounds to the nearest n dp, we want a function that rounds down
Round(5.678,2) = 5.68
RoundDown(5.678,2)=5.67
-
Jul 30th, 2000, 02:07 PM
#11
transcendental analytic
Why not just:
Round(5.678-0.005,2) = 5.67
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 30th, 2000, 04:56 PM
#12
Thread Starter
Frenzied Member
NXSupport - Your one-stop source for computer help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|