comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Multiplying fixed-point by long integer
Date: Thu, 04 Oct 2012 21:23:21 -0700
Date: 2012-10-04T21:23:21-07:00	[thread overview]
Message-ID: <k4lnbs$2met$1@adenine.netfront.net> (raw)
In-Reply-To: <b06c0b56-3f3c-42e9-8b3a-76a4a27fc1cc@googlegroups.com>

On 10/04/2012 06:46 PM, Adam Beneschan wrote:
>
> 4.5.5 defines predefined multiplication operators between any fixed-point
> type and Integer.  However, it isn't defined for any other integer type.
> This can cause a problem if I have an integer type whose bounds are larger
> than Integer, since it obviously won't work to convert it to Integer.  Has
> anyone encountered this problem before, and how did you solve it?  I'm
> hesitant to try to solve it by converting things to floating point, since the
> mantissa of a floating-point may have fewer bits than the fixed-point or
> integer type, and fixed-point multiplication by an integer should be exact.

Do the integer values fit in the range of the fixed-point type? If so, you could 
convert to the fixed-point type.

If not, then the fixed-point abs value must be < 1, and you're dividing the 
integer value by 1/'Small. That might give you some idea how to proceed.

-- 
Jeff Carter
"C++ is vast and dangerous, a sort of Mordor of
programming languages."
Jason R. Fruit
120

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---



  parent reply	other threads:[~2012-10-11  7:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-05  1:46 Multiplying fixed-point by long integer Adam Beneschan
2012-10-05  2:12 ` Shark8
2012-10-05  4:23 ` Jeffrey Carter [this message]
2012-10-05  4:25 ` tmoran
2012-10-05 15:41   ` Adam Beneschan
2012-10-05  5:14 ` anon
2012-11-06 17:20 ` Jacob Sparre Andersen
2012-11-06 20:33   ` Adam Beneschan
replies disabled

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