MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Can you round number to the nearest x?


In a message dated 8/19/2000 4:58:38 AM, owenzooey at my-deja.com writes:

>Looking through the standard functions I cannot find a way to round a
>number to the nearest 5 or 10 or whatever.  Is there a somewhat simple
>way to do this before I do it the hard way?

genRound[x_, incr_:1] := incr*Round[x/incr]

Table[{x = 100*Random[], Round[x] == genRound[x], genRound[x, 0.25], 
      genRound[x, 0.1], genRound[x, 5], genRound[x, 10]}, {10}] // TableForm


Bob Hanlon


  • Prev by Date: Re: Can you round number to the nearest x?
  • Next by Date: Re: Using output of a Fit
  • Previous by thread: Re: Can you round number to the nearest x?
  • Next by thread: RE: Can you round number to the nearest x?