unpack('>f', b'\x00\x01\x00\x00')
Mark Dickinson
mdickinson at enthought.com
Fri Dec 2 11:25:25 EST 2011
On Dec 1, 10:21 am, Hrvoje Niksic <hnik... at xemacs.org> wrote:
> Chris Rebert <c... at rebertia.com> writes:
> > C does not have a built-in fixed-point datatype, so the `struct`
> > module doesn't handle fixed-point numbers directly.
>
> The built-in decimal module supports fixed-point arithmetic, but the
> struct module doesn't know about it. A bug report (or patch) by someone
> who works with binary representations of fixed-point would be a good
> start to improve it.
Not really: the decimal module is for floating-point, not fixed-
point, though its semantics for significant trailing zeros can help
give the appearance of fixed-point arithmetic for simple operations
(addition, subtraction) that stay within suitable bounds. And decimal
fixed-point isn't so much use for a binary fixed-point format, anyway.
--
Mark
More information about the Python-list
mailing list