ShortFloat.st
changeset 14922 30546dbb18c6
parent 14920 5b452cc39879
child 14924 7115c6830ed8
--- a/ShortFloat.st	Wed Mar 20 15:57:16 2013 +0100
+++ b/ShortFloat.st	Wed Mar 20 16:01:14 2013 +0100
@@ -362,7 +362,18 @@
 
 readBinaryIEEESingleFrom:aStream into:aFloat
     "read a float value from the binary stream, aStream,
-     interpreting the next bytes as an IEEE formatted 4-byte float"
+     interpreting the next bytes as an IEEE formatted 4-byte float.
+     The bytes are read in the nativ byte order (i.e.lsb on intel)"
+
+    ^ self readBinaryIEEESingleFrom:aStream into:aFloat MSB:(UninterpretedBytes isBigEndian)
+
+    "Modified: / 23-08-2006 / 16:01:52 / cg"
+!
+
+readBinaryIEEESingleFrom:aStream into:aFloat MSB:msb
+    "read a float value from the binary stream, aStream,
+     interpreting the next bytes as an IEEE formatted 4-byte float.
+     If msb is true, the stream bytes are most-significant-first."
 
     aFloat class == self ifFalse:[self error:'no a ShortFloat'].
 
@@ -373,15 +384,15 @@
     "
     self isIEEEFormat ifFalse:[self error:'unsupported operation'].
 
-    UninterpretedBytes isBigEndian ifFalse:[
-	"swap the bytes"
-	4 to:1 by:-1 do:[:i |
-	    aFloat basicAt:i put:(aStream next)
-	].
-	^ self
+    (UninterpretedBytes isBigEndian == msb) ifFalse:[
+        "swap the bytes"
+        4 to:1 by:-1 do:[:i |
+            aFloat basicAt:i put:(aStream next)
+        ].
+        ^ self
     ].
     1 to:4 do:[:i |
-	aFloat basicAt:i put:aStream next
+        aFloat basicAt:i put:aStream next
     ]
 
     "not part of libboss, as this is also used by others (TIFFReader)"
@@ -1848,10 +1859,10 @@
 !ShortFloat class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.119 2013-03-20 14:57:14 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.120 2013-03-20 15:01:14 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.119 2013-03-20 14:57:14 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ShortFloat.st,v 1.120 2013-03-20 15:01:14 cg Exp $'
 ! !