Path: news.mathworks.com!newsfeed-00.mathworks.com!NNTP.WPI.EDU!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to round to 2 decimal?
Date: Wed, 5 Mar 2008 00:26:27 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 21
Message-ID: <fqkpbj$72h$1@canopus.cc.umanitoba.ca>
References: <fqjpma$66c$1@fred.mathworks.com> <fqkn97$hnn$1@fred.mathworks.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1204676787 7249 192.70.172.160 (5 Mar 2008 00:26:27 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Wed, 5 Mar 2008 00:26:27 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:455408


In article <fqkn97$hnn$1@fred.mathworks.com>, Dan Haeg <haegd@msoe.edu> wrote:
>"Deo " <spliers@hotmail.com> wrote in message
><fqjpma$66c$1@fred.mathworks.com>...
>> hey, how can I set my matlab program to round all the 
>> double numbers to 2 decimals

>here is one way:
>
>data=round(data*100)/100

>> data=pi; data=round(data*100)/100; sprintf('%.60g', data)

ans =

3.140000000000000124344978758017532527446746826171875

Why didn't I get 3.14 exactly? I followed your steps word for word!
Is sprintf broken???
-- 
  "All human knowledge takes the form of interpretation."
                                              -- Walter Benjamin