constant floating point values

James Hague james.hague@REDACTED
Mon Oct 25 02:12:05 CEST 2010

Let's say I call an external function like this:

   my_module:add(1.0, 2.0)

I think what happens right now--from looking at the BEAM code--is that 1.0
is created on the heap (12 bytes in the 32-bit emulator) and 2.0 is created
on the heap (another 12 bytes). Then pointers to those two floats are passed
as parameters to the external function.

What's the technical reason that BEAM doesn't support constant floats, the
same way as constant tuples and lists?

(Note that in expressions where floating point math can be determined at
compile time, such as "A * 2.5", then the value 2.5 is treated as a constant
value and loaded directly into a virtual floating point register. Nice!)

More information about the erlang-questions mailing list