[Newbies] Reading and writing C structs
Ramiro Diaz Trepat
ramiro at diaztrepat.name
Tue Jul 1 23:45:35 UTC 2008
Yes, if you can load the contents on a ByteArray you can use the method:
array floatAt: position
It works just fine to read contents written from a C program, and I think it
is a bit simpler.
Cheers.
r.
On Wed, Jul 2, 2008 at 12:36 AM, David Finlayson <dfinlayson at usgs.gov>
wrote:
> Thanks. The following methods work, can they be improved/simplified?
>
> double
> " returns a double "
> | n a b |
> a := self uint32.
> b := self uint32.
> n := Float new: 2.
> n at: 1 put: b.
> n at: 2 put: a.
> ^n
> float
> " returns a float "
> ^Float fromIEEE32Bit: self uint32.
>
> uint32
> " Answer the next unsigned, 32-bit integer from this little endian
> (binary) stream "
> ^ aFileStream nextLittleEndianNumber: 4
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20080702/f0459d33/attachment.htm
More information about the Beginners
mailing list