From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.152.45.5 with SMTP id i5mr11423630lam.2.1384196046259; Mon, 11 Nov 2013 10:54:06 -0800 (PST) Path: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!s18no770334wiv.0!news-out.google.com!ft6ni11294wib.1!nntp.google.com!proxad.net!feeder1-2.proxad.net!137.226.231.214.MISMATCH!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Oliver Kleinke Newsgroups: comp.lang.ada Subject: Re: A curiosity about decimal fixed point types... Date: Mon, 11 Nov 2013 19:54:05 +0100 Organization: A noiseless patient Spider Message-ID: <20131111195405.30842cb7@PC-8N-L> References: <7d4f2e0c-0aed-4ba3-aa5a-0c2bc0c2c5a0@googlegroups.com> Mime-Version: 1.0 Injection-Info: mx05.eternal-september.org; posting-host="434901b96fa29c45bb85d71213c80cc9"; logging-data="2948"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/DlPdHupXHELVQe/50cdC3iJfmiw5yx7Q=" X-Newsreader: Claws Mail 3.9.2 (GTK+ 2.24.21; x86_64-pc-linux-gnu) Cancel-Lock: sha1:7giUNDFTTyUuN1SHHrp4GkrfVmQ= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Original-Bytes: 2447 Xref: number.nntp.dca.giganews.com comp.lang.ada:183821 Date: 2013-11-11T19:54:05+01:00 List-Id: Am Mon, 11 Nov 2013 07:04:12 -0800 (PST) schrieb mockturtle : > Dear all, > just a silly curiosity about decimal fixed point types, e.g., > > type Euro is delta 0.01 digits 20; > -- Would be 20 enough? :-) > > Are they currently used? Where? Since most of the examples are about > money (mine and RM's) included, I guess that they were thought for > financial applications, but I am unsure if nowadays financial > software uses this type of types or just floating point. > > Best regards > > Riccardo > Hi Riccardo, The type definition that you provided is a good example for using fixed point types for accurate representation. With a fixed-point type you can avoid the occasional precision problems that floating-point types suffer from. (For example if I type "0.1 + 0.2" in my Python-interpreter it yields 0.30000000000000004.) This can be very important if you sum up/integrate a range of measurement data obtained from a sensor -- for example a gyro. Also, on some machines fixed-point arithmetic 'might' be faster than floating-point arithmetic -- e.g. machines without FPU -- but I guess that also very much depends on the operations and the compiler, &c.