Path: news.mathworks.com!newsfeed-00.mathworks.com!nlpi057.nbdc.sbc.com!prodigy.net!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!u18g2000pro.googlegroups.com!not-for-mail From: "Felipe G. Nievinski" <fgnievinski@gmail.com> 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) Organization: http://groups.google.com Lines: 38 Message-ID: <38a474ec-5629-475a-8f01-f094e5969d5f@u18g2000pro.googlegroups.com> References: <545015a5-3f51-41e3-a40b-1cf7db531b11@35g2000pry.googlegroups.com> <ghfobu$blk$1@fred.mathworks.com> <fac1f966-62ff-427d-b67c-7cce5297f210@v5g2000prm.googlegroups.com> <ghgf9m$ds5$1@news.motzarella.org> NNTP-Posting-Host: 128.138.43.113 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1228668715 22756 127.0.0.1 (7 Dec 2008 16:51:55 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 7 Dec 2008 16:51:55 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: u18g2000pro.googlegroups.com; posting-host=128.138.43.113; posting-account=iCBMwwoAAAARtxHOK9kIhRHsTae4FBZX 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/0.4.154.29 Safari/525.19,gzip(gfe),gzip(gfe) Bytes: 3044 Xref: news.mathworks.com comp.soft-sys.matlab:505469 sci.math.num-analysis:105703 On Dec 7, 5:24=A0am, Martin Eisenberg <martin.eisenb...@udo.edu> 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, though. Felipe.