Message28447
| Author |
chrish42 |
| Recipients |
| Date |
2006年05月08日.17:05:07 |
| SpamBayes Score |
| Marked as misclassified |
| Message-id |
| In-reply-to |
| Content |
When using struct to unpack floats, I'm getting
inconsistent results when using the '<d' specification
instead of '@d' on a little-endian machine (Intel).
Here's a short python snippet that demonstrates the
problem.
import sys, struct
s = '\x00\x00\x00\x00\x00\x00\xf8\x7f'
>>> sys.byteorder
'little'
# This is correct...
>>> struct.unpack('@d', s)
(nan,)
# These should be equivalent for unpacking a single
# double on little-endian arch... but they're not.
>>> struct.unpack('<d', s)
(inf,)
>>> struct.unpack('=d', s)
(inf,)
|
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2007年08月23日 14:39:55 | admin | link | issue1483963 messages |
| 2007年08月23日 14:39:55 | admin | create |
|