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

Denis Kudriashov dionisiydk at gmail.com
Wed Apr 12 15:45:54 UTC 2017


2017-04-12 17:42 GMT+02:00 Bert Freudenberg <bert at freudenbergs.de>:

> 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.
>

Nice trick. Thank's
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20170412/0be7a993/attachment.html>


More information about the Vm-dev mailing list