Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: Can you round number to the nearest x?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24908] Re: [mg24871] Can you round number to the nearest x?
  • From: BobHanlon at aol.com
  • Date: Sun, 20 Aug 2000 01:34:56 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

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?