[Vm-dev] [VM-dev] How serialize/materialize SmallFloat64?

Bert Freudenberg bert at freudenbergs.de
Wed Apr 12 15:42:31 UTC 2017


On Wed, Apr 12, 2017 at 5:25 PM, Denis Kudriashov <dionisiydk at gmail.com>
wrote:

>
> I tested my serialization library on 64bits image and tests for floats are
> failed.
> For boxed floats I use #basicNew. And SmallFloat signal error
> 'SmallFloat64s can only be created by performing arithmetic'
>
> So question how implement smallfloat serialization/materialization ?
>

SmallFloats still support word access via basicAt:

| a x y |
x := 0.5.
a := {x at: 1. x at: 2}.
y := BoxedFloat64 new.
y at: 1 put: (a at: 1).
y at: 2 put: (a at: 2).
y := y * 1.0.
{x. x class. a. y. y class} {0.5 . SmallFloat64 . #(1071644672 0) . 0.5 .
SmallFloat64}

So to serialize you just use the words. And to deserialize you just create
a BoxedFloat. If you want to normalize the boxed float you do some
arithmetic operation on it. But boxed floats work fine for any value, it's
just a space optimization.

- Bert -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20170412/16b6838f/attachment.html>


More information about the Vm-dev mailing list