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