Re: Swapping is inefficient and wasteful

From: Brian Hetrick (bhetrick_at_notinnedmeats.iname.com)
Date: 11/24/04


Date: Wed, 24 Nov 2004 08:11:57 -0500


"Ernst Lippe" <ernstl-at-planet-dot-nl@ignore.this> wrote ...
> That depends on the bitsize of your floats, in this way you
> can get only 2**24 different output values, and when your
> floats have a mantissa of more than 24 bits there are some
> output values that your algorithm can't produce.

True. However, an IEEE single has 24 significant bits, which seems a
reasonable number to use in an example. If there is a need for more
significant bits, the obvious extension can be used.

More interesting, because more common, is the need for an unbiased
choice among a set of alternatives on machines (such as microcontrol-
lers) where there is no floating point unit. Rather than construct a
floating point package, you can join two random bytes to form a sample
from U{0,1,...,65535}, multiply by the (say, one-byte) number of
alternatives, and take the top byte of the three-byte product.



Relevant Pages

  • Re: Swapping is inefficient and wasteful
    ... >> That depends on the bitsize of your floats, in this way you can get only ... > More interesting, because more common, is the need for an unbiased choice ... Rather than construct a floating point ...
    (sci.crypt)
  • Re: Swapping is inefficient and wasteful
    ... > That depends on the bitsize of your floats, ... > floats have a mantissa of more than 24 bits there are some ... the values are "quantized" into bins. ...
    (sci.crypt)
  • Re: Floating point bug?
    ... "never test floats for equality". ... [end quote] ... you often do want to test floating point values within some ...
    (comp.lang.python)
  • Re: Floating-point arithmetic in CL
    ... > rationals, not as floating point. ... wants binary floating point, he should specify his constants in ... Programmers were *acutely* aware of the difference ... floats add at the same speed as integers. ...
    (comp.lang.lisp)
  • Re: Dan Bruce on guitar
    ...  In some respects McLaughlin floats in that he ... doesn't anchor with his pinky. ... at least over the bridge. ... Now, if that is the only benefit you derive from floating, ...
    (rec.music.makers.guitar.jazz)