From: Jacob Sparre Andersen <sparre@nbi.dk>
Subject: Re: Truncating a fixed-point value
Date: Tue, 13 Jul 2010 13:26:49 +0200
Date: 2010-07-13T13:26:49+02:00 [thread overview]
Message-ID: <87hbk3pqpy.fsf@hugsarin.sparre-andersen.dk> (raw)
In-Reply-To: 5a96a81e-12a6-4f30-84c3-4b76e079b198@l25g2000prn.googlegroups.com
Adam Beneschan wrote:
> That will probably work for my purpose; but in general, it's easy to
> define a fixed-point number with a 'Small of 2**(-N) that has more
> bits to the right of the binary point than are available in the
> mantissa part of the floating-point. If that's the case, this
> approach will fail on certain values (probably M - (K * T'Small) for
> integer M and suitably small integer K). Since this situation lends
> itself to really efficient code (basically just a bit shift), it's
> kind of a shame that the language doesn't give you a good way to do
> this.
Isn't it possible to write a truncation function, which uses bit shift
when it is appropriate? If the 'Small is statically known, there is a
fair chance that the compiler will remove the unused branch at
compile-time.
Jacob
--
"If we weren't at least occasionally surprised by the results,
we might as well save ourselves the trouble of measuring :)"
next prev parent reply other threads:[~2010-07-13 11:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-09 19:06 Truncating a fixed-point value Adam Beneschan
2010-07-09 20:34 ` Simon Wright
2010-07-09 23:21 ` Adam Beneschan
2010-07-10 3:13 ` Gene
2010-07-11 19:43 ` Gene
2010-07-10 8:12 ` Simon Wright
2010-07-09 20:39 ` Gene
2010-07-09 21:20 ` Jeffrey R. Carter
2010-07-09 21:52 ` Adam Beneschan
2010-07-13 11:26 ` Jacob Sparre Andersen [this message]
2010-07-09 22:58 ` Shark8
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox