Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ROUNDING NUMBERS: Which method do you use? SEE MANY METHODS
#21
Oracle, there is a very good reason: It's faster. Smile

(And it's not the "programmers" who are sloppy; the rounding is done in the FPU.)
Reply
#22
It's not errors in the code, it is just a different method intended to avoid bias. The important thing is knowing how it behaves, so that your program will do what you expect it to do.
Code:
INT(x)                         rounds to the nearest integer at or below x (the floor)
-INT(-x)                       rounds to the nearest integer at or above x (the ceiling)
INT(x + .5)                    rounds up for .5 and up down for under .5
CINT                           rounds .5 to nearest even number otherwise to the nearest number
SGN(x) * INT(ABS(x) + .5)      rounds .5 away from zero, otherwise to the nearest number

Moneo,
I use the ceiling function for color assignment in my fractals, and I often use the floor (INT) but I can't think of a specific example right now. They do have their uses, and are recognized mathematical functions.
hrist Jesus came into the world to save sinners, of whom I am first.(I Timothy 1:15)

For God so loved the world, that He gave His only begotten Son,
that whoever believes in Him should not perish, but have eternal life.(John 3:16)
Reply
#23
Plasma: Faster, eh? I don't doubt you, but don't you think that big software companies should provide the .5 up method as an inbuilt function? Because that's the way much of the world understands rounding...

SCM: INT(RND * num) + 1 Smile
Reply
#24
Is it really that hard to add .5?

Code:
DEF FNround (number) = INT(number + .5)

C'mon, there's no arcsine function either, but nobody's whining about that.
Reply
#25
That doesn't work for negatives Smile That's the problem that is solved by my function in the very first post, you're a wee bit behind Smile

And Glenn has an arcsine function Smile If he's alive, that is Wink
Reply
#26
Er, I know that...and I know other people have written arcsine functions. The point is that QB doesn't have EVERY math function, and it shouldn't.
Reply
#27
ORACLE and SCM:
You 2 guys have shown that you really understand the issue of various rounding methods, and how to determine which you should use. Thanks for sharing your thoughts and experience.

PLASMA:
Before you go making off-the-wall remarks, you should first read up on the rounding subject, and do some testing of the functions provided in QB with both positive and negative numbers. Then you'll be in a position to voice an opinion. For starters, read the following Microsoft page regarding rounding:
http://support.microsoft.com/default.asp...us;Q196652
*****
Reply
#28
MONEO:
I don't think any of my remarks are off the wall. I know how QB's functions work. Just because I didn't waste 3 weeks of my life researching rounding doesn't mean I don't know anything.

(Don't think that because Glenn's not here you get promoted to Captain Badass. Tongue)
Reply
#29
Quote:MONEO:
I don't think any of my remarks are off the wall. I know how QB's functions work. Just because I didn't waste 3 weeks of my life researching rounding doesn't mean I don't know anything.

(Don't think that because Glenn's not here you get promoted to Captain Badass. Tongue)
PLASMA:
First of all, you jumped into this thread 17 days late.
The following are 3 of your remarks which apparently don't show much understanding about rounding nor how QB functions work. Also, your insistent criticism of my spending 3 weeks researching rounding, I thing makes you a better candidate for the "Captain Badass" title.

1) You spent 20 hours looking for stuff about rounding?!....damn, and I thought I wasted a lot of time...

2) There ain't that much to it. .5 or higher, you round up. Otherwise you round down.

3) Is it really that hard to add .5?
*****
Reply
#30
First of all, I wasn't aware that I had to reply on the first day a message was posted for my opinions to be considered valid.

Second, I find nothing wrong with those statements that you think are "off the wall":

1) is a joke and it's my opinion
2) is the "common" method of rounding
3) was a response to oracle complaining about QB not having a rounding function that follows his rules

And none of those statements have anything to do with QB's functions, so I fail to see how you think that my understanding of QB's functions are lacking. (Thus making you, sir, Captain Badass.)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)