The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: how to round to 2 decimal?
Replies: 12   Last Post: Oct 18, 2015 7:19 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Walter Roberson

Posts: 5,173
Registered: 2/26/06
Re: how to round to 2 decimal?
Posted: Mar 4, 2008 12:36 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

In article <fqjpru$lpj$>,
Walter Roberson <> wrote:
>If you were to try to round
>(say) pi to 2 decimal places then the value stored internally
>would not correspond to 3.14 but instead to approximately
>3.14 + 2e-15

Small correction: the result is
3.14 + 1.24344978758017532527446746826171875e-16

>> sprintf('%0.60g',3.14)

ans =


"All human knowledge takes the form of interpretation."
-- Walter Benjamin

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.