comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Numerical calculations: Why not use fixed point types for everything?
Date: Fri, 18 Jan 2013 10:59:43 -0800 (PST)
Date: 2013-01-18T10:59:43-08:00	[thread overview]
Message-ID: <13febf5c-4e3c-4275-8ff4-0a3a9e885d31@googlegroups.com> (raw)
In-Reply-To: <3l3jf85ae05qgsl2l0avomebmg2ogl17rq@invalid.netcom.com>

On Friday, January 18, 2013 10:15:06 AM UTC-8, Dennis Lee Bieber wrote:

> 	Integer operations may be faster than floating point... But fixed
> point with a non-zero decimal place add in the overhead of having to
> track where the point is and shifting results to match the declared data
> type.
> 
> 25 * 25 => 725
> 
> 2.5 * 2.5 => 7.25 -- but if the data type is only one decimal place this
> now has to be rounded and shifted to become 7.3.

Perhaps.  But I tend to assume my computer is going to return correct arithmetical results, which none of the above are.  :(

In general, of course you're right that if your values aren't represented with enough precision, or with a scale factor that will require rounding, you're going to run into problems.  But of course that's a problem with floating-point as well as with fixed-point.  If the range of values is small enough, you can actually declare fixed-point types that have greater precision than the available floating-point types.  And how much precision is necessary depends on the problem domain.  And there's no reason to assume that all values in your program have to have the same scale factor--in fact, Ada's definition of fixed-point multiplication and division operations supports cases where an intermediate result may have more precision than the operands, and rounding can wait until the final expression result is computed.

                        -- Adam



  reply	other threads:[~2013-01-18 18:59 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-17 10:33 Numerical calculations: Why not use fixed point types for everything? Ada novice
2013-01-17 14:40 ` Nasser M. Abbasi
2013-01-17 16:16   ` Adam Beneschan
2013-01-17 17:00     ` Georg Bauhaus
2013-01-17 16:25 ` Adam Beneschan
2013-01-18  9:17   ` Ada novice
2013-01-18 17:24     ` J-P. Rosen
2013-01-18 17:52       ` Jeffrey Carter
2013-01-18 18:15     ` Dennis Lee Bieber
2013-01-18 18:59       ` Adam Beneschan [this message]
2013-01-19  4:41         ` Dennis Lee Bieber
2013-01-19  6:26           ` Jeffrey Carter
2013-01-19 14:14             ` Robert A Duff
2013-01-25 12:16               ` Paul Colin Gloster
2013-01-24 10:55             ` Ada novice
2013-01-24 11:47               ` Simon Wright
2013-01-24 14:21                 ` Ada novice
2013-01-20  0:05           ` Robin Vowels
2013-01-18 23:06       ` Robin Vowels
2013-01-18 19:09     ` Adam Beneschan
2013-01-18 21:39       ` Randy Brukardt
2013-01-19  7:02         ` Ada novice
2013-01-25 12:09         ` Paul Colin Gloster
2013-01-25 12:23     ` Paul Colin Gloster
2013-01-28  9:09       ` Ada novice
2013-02-01 10:53         ` Ada novice
2013-02-01 15:01           ` Shark8
2013-02-02 18:55             ` Ada novice
2013-02-03  4:05               ` Shark8
2013-02-04  6:23                 ` Ada novice
2013-02-04  6:43                   ` Niklas Holsti
2013-02-04  7:27                     ` Ada novice
2013-02-04  9:37                       ` Niklas Holsti
2013-02-04 10:09                         ` Ada novice
2013-02-04 14:24                           ` Niklas Holsti
2013-02-04 16:44                             ` Jeffrey Carter
2013-02-04 21:12                               ` Niklas Holsti
2013-02-04 17:31                             ` Robert A Duff
2013-02-04 21:20                               ` Niklas Holsti
2013-02-02 21:08           ` Nasser M. Abbasi
2013-02-04  6:17             ` Ada novice
2013-02-05  2:27               ` Randy Brukardt
2013-02-06  7:11                 ` Ada novice
2013-02-07  6:03                   ` Randy Brukardt
2013-02-07  8:43                     ` Shark8
2013-02-08  3:17                       ` Randy Brukardt
2013-02-08  6:20                     ` Ada novice
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox