From: "Felipe G. Nievinski" <>
Newsgroups: comp.soft-sys.matlab,sci.math.num-analysis
Subject: Re: robust truncation at n decimal places
Date: Sun, 7 Dec 2008 08:51:54 -0800 (PST)
Lines: 38
Message-ID: <>
References: <> 
	<ghfobu$blk$> <> 
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: 1228668715 22756 (7 Dec 2008 16:51:55 GMT)
NNTP-Posting-Date: Sun, 7 Dec 2008 16:51:55 +0000 (UTC)
Injection-Info:; posting-host=; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) 
	AppleWebKit/525.19 (KHTML, like Gecko) Chrome/ Safari/525.19,gzip(gfe),gzip(gfe)
Bytes: 3044
Xref: comp.soft-sys.matlab:505469 sci.math.num-analysis:105703

On Dec 7, 5:24=A0am, Martin Eisenberg <> wrote:
> Felipe G. Nievinski wrote:
> > I could try to generalize ismember() -- in the past, I've
> > generalized unique(x, tol) -- but since my input data is given at
> > finite precision, I find it reasonable to expect exact equality,
> > after rounding/truncation. (My time tags are given in the format
> > year month day hour minute seconds -- all fields are integers
> > except seconds, which has seven decimal places. I end up with
> > decimals beyond the seventh place because I convert them
> > through datenum()).
> Narrowly construed, what you want is impossible
Well, what I want (as defined in the test cases above) is possible
with sprintf/sscanf -- I'm just looking for a computationally cheaper
algorithm, avoiding conversion to/from char strings.

> because for any given
> number of decimal digits, many numbers thus representable don't have
> terminating (but only periodic) binary expansions. What is your
> seconds field's original representation?
Seconds are given as a base 10 decimal number with seven significant
figures, e.g., 14.9999999 s.
Perhaps it's important to mention that my events are widely spaced in
time (e.g., usually 1 s apart) compared to the time tags precision
(1e-7 s).

> Does the path it takes
> warrant the idea of containing exactly seven decimal places by the
> time you get to the current point?
I don't understand what you mean by "path".

Thanks for your comments.

I'm still on the lookout for a robust rounding without sprintf/sscanf,