Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
rounding to ............
#11
Sterling,
I appreciate your efforts in correcting my algorithms, but THEY WERE NEVER INTENDED TO DO ROUNDING.

Please notice that the definition of each algorithm says COMPUTE THE NEAREST MULTIPLE and COMPUTE THE NEXT MULTIPLE.

Athough it's not readily apparent, I never intended the input number to be negative or to have decimal places. To consider these, they would no longer be one line algorithms.

So, based on all of this:
* My NEXT solution will always move UP to the next multiple.
* My NEAREST solution will either move UP or stay where it is.

Neither will ever ROUND DOWN. That's not what this is about. In Zha's original post he did use the word "round", although his example was not about rounding, but moving or positioning to the next multiple of 5.

The bit about CINT, yeah it's funny. It's almost as funny as the results you get when testing positive and negative numbers where the decimal part is ".5".
*****
Reply
#12
Quote:isn't it funny that it didn't occur to us before dark_prevail reminded us? Instead we all posted more complicated stuff... Ok well, at least I thought it was funny.

it takes a simple person to see a simple solution Big Grin
Reply
#13
Moneo: I quote (my emphasis):
Quote:can some one tell me how to round the the number to the nearest 5 plz!!!!!!!!!
Nearest means 1 rounds down to 0, not to 5.
Reply
#14
Sterling,
You're entitled to your interpretation,
no matter how wrong it may be. :wink:

Why don't we ask ZHA what he meant?
*****
Reply
#15
Quote:no matter how wrong it may be. :wink:
:???: I don't get it. How could you possibly think that from 1, 5 is nearer than 0? You must be working with a really weird definition of the word near.

Don't you remember the rounding rules you must have learned in grade school?
The teacher probably had you practice rounding to the nearest ten, and for that you should have been taught to round down if the last digit was 4 or less, and up if the last digit was 5 or more.
Reply
#16
Sterling,

Will you accept my using the word NEXT to mean advance to the next multiple?

If you accept this, then let me tell you the rest of the story. Back in 1993, in a real production program, I needed to find the NEXT multiple of a whole, positive, non-zero number. That's when I derived the algorithm for NEXT.

Soon thereafter, I realized the need not to advance to the next multiple if I was already sitting on a multiple. That's when I derived the NEAREST algorithm. I couldn't think of a better term than NEAREST at the time, nor can I now.

You may not like my definition of the term NEAREST, but since it's concerned with my algorithm, it's my choice of wording.

I have made an effort in this response not to be insulting.
*****
Reply
#17
Quote:I have made an effort in this response not to be insulting.
You've never insulted or offended me, Moneo. I'm sorry if I sounded that way. Sometimes I just get carried away when I argue. At first I was just poking at you in dark_prevail's defense because I was bored, and then the name NEAREST didn't make sense...

Maybe I should lighten up my posts a bit and put in smilies whenever I'm arguing just for the sake of arguing so that people know not to take it too seriously or personally. Anway, I'm sorry, and no offense was ever intended. :oops:
Reply
#18
That's ok, Sterling, I understand.
Have a Happy New Year,
and don't eat any yellow snow. :wink:
*****
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)