comp.lang.ada
 help / color / mirror / Atom feed
From: Robin Vowels <robin.vowels@gmail.com>
Subject: Re: Numerical calculations: Why not use fixed point types for everything?
Date: Fri, 18 Jan 2013 15:06:57 -0800 (PST)
Date: 2013-01-18T15:06:57-08:00	[thread overview]
Message-ID: <23f3f31f-1f8b-4f04-98ce-025b7a81e3e0@th3g2000pbc.googlegroups.com> (raw)
In-Reply-To: 3l3jf85ae05qgsl2l0avomebmg2ogl17rq@invalid.netcom.com

On Jan 19, 5:15 am, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote:
> On Fri, 18 Jan 2013 01:17:37 -0800 (PST), Ada novice <shai.l...@gmx.com>
> declaimed the following in comp.lang.ada:
>
>
>
> > I have read (John Mc Cormick: Building parallel...with Ada's book) that fixed point arithmetic is faster than floating-point arithmetic since integer instructions are faster so I would ask about the second point put by Adam that mathematical functions are slow with fixed-point numbers. Can you please elaborate on that?
>
>         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.
>
>         All these adjustments and tracking are being done at the high-level
> instruction set, not in the processor hardware. In contrast, a floating
> point processor does all the mantissa and exponent adjustments in the
> hardware, which may be faster than having to do things like --
>
> ld i1, 25
> mult i1, 25
> add i1, 5
> div i1, 10

It may not be like that at all.
In the first place, 25 is a constant.
In the second place, adjusting the value (scaling) is achieved
with a shift, not an actual division by 10.
Thus, multiplication is simply
multiply a,b
shift.rounded a

> -- the sequence to treat integer registers as fixed 1-decimal place data
> compared to (the add/div would be added by the compiler based upon the
> number of decimal places to be kept in the result, based upon the number
> of places that were in the source
>
> ld f1, 2.5E0
> mult f1, 2.5E0



  parent reply	other threads:[~2013-01-18 23:06 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
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 [this message]
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