Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*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 2005

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

Search the Archive

Re: Rounding?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60888] Re: [mg60881] Rounding?
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 2 Oct 2005 01:54:40 -0400 (EDT)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

SetAccuracy does not truncate the number

-0.06251234//InputForm

-0.06251234

SetAccuracy[%,4]//InputForm

-0.0625123399999999996`2.795965755982742

To round numbers

myRound[x_,p_:1]:=Round[x/p]*p;

myRound[-0.06251234,#]& /@ {0.0001,0.001,1/16}//InputForm

{-0.0625, -0.063, -1/16}


Bob Hanlon

> 
> From: Tom De Vries <tom_toad at telus.net>
To: mathgroup at smc.vnet.net
> Date: 2005/10/01 Sat AM 02:55:59 EDT
> Subject: [mg60888] [mg60881] Rounding?
> 
> Hello everyone,
> 
> Sorry if this is an obvious question.  I'm wondering why the two results
> below are different?
> 
> I'm creating programs to generate test questions, and I need to know that my
> computer generated answers will match the student answers, to say, three
> decimal places.  So the answer is -0.0625  "exactly", the first result makes
> sense to me, the second doesn't.
> 
> If there is a reason for this, is there are way to insure I can make the
> first result look like the second result all the time??
> 
> 
> SetAccuracy[-0.0625,4]
> 
> -0.063
> 
> ToString[SetAccuracy[-0.0625,4]]
> 
> -0.062
> 
> 
> Thanks for your input!
> 
> 
> Tom De Vries
> 
> 


  • Prev by Date: Re: Finding length in recursive definition?
  • Next by Date: Re: Rounding?
  • Previous by thread: Re: Rounding?
  • Next by thread: Plotting 2 graphics with different scale