I'm trying to create a typed FloatArray. There's not a lot in the system for converting floats to bytes, so I hacked up something where I use basicAt: to extract the first and second dwords, and then strip the dwords down a byte at a time (a bit more complex then VW where changeClassToThatOf: #[] works handily). But now that I've got it ripped down into 8 bytes, I can't figure out how to get the float back again. I put the 4 byte chunks back together (via bitShift: and +), but can't use basicAt:put: on an instance of a float. Feature, bug,...? Is there a better way to do this anyway?
Travis Griggs
I bet you forgot to use Float new: 2 instead of just Float new (which defaults to new: 1). [This should probably be fixed]
Try the following example:
| r | r := Float new: 2. r basicAt: 1 put: (Float pi basicAt: 1). r basicAt: 2 put: (Float pi basicAt: 2). r
- Dan
Dan Ingalls wrote:
I'm trying to create a typed FloatArray. There's not a lot in the system for converting floats to bytes, so I hacked up something where I use basicAt: to extract the first and second dwords, and then strip the dwords down a byte at a time (a bit more complex then VW where changeClassToThatOf: #[] works handily). But now that I've got it ripped down into 8 bytes, I can't figure out how to get the float back again. I put the 4 byte chunks back together (via bitShift: and +), but can't use basicAt:put: on an instance of a float. Feature, bug,...? Is there a better way to do this anyway?
Travis Griggs
I bet you forgot to use Float new: 2 instead of just Float new (which defaults to new: 1). [This should probably be fixed]
Try the following example:
| r | r := Float new: 2. r basicAt: 1 put: (Float pi basicAt: 1). r basicAt: 2 put: (Float pi basicAt: 2). r
Yup. That was it. Actually I used Float basicNew which made it's size 0. Thanks much!
Travis Griggs
I was wondering if there is any way to get a bulk digest of the squeak-list archives. I mean as one file per (year/month), not one file per email.
Incidentally, the last message to the list was 4000!
http://squeak.cs.uiuc.edu/mail/squeak/msg04000.html
-- Mike Klein
squeak-dev@lists.squeakfoundation.org