Re: Passing floats/doubles to C

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Sun, 13 Feb 2000 13:45:22 -0500, Robert Craig <rds at ATTCANADA.NET> wrote:

>Todd Riggins writes:
>> poke4(material,      atom_to_float64(1.0))
>> poke4(material+8,  atom_to_float64(1.0))
>> ...
>
>atom_to_float64() returns a sequence of 8 bytes - a C double.
>Use poke(material, atom_to_float64(1.0))
>to store the 8 bytes in memory.
>poke4 will actually store 4*8 = 32 bytes - wrong.
>
>If you decide to use atom_to_float32() to store C *floats*,
>you can also use poke() to store the 4 bytes.
>
>Regards,
>   Rob Craig
>   Rapid Deployment Software
>   http://www.RapidEuphoria.com

A minor help in this situation would be some better documentation in the
manual. An even more minor glitch is this error in the manual:

poke Syntax:
poke(a, x)
Description:
If x is an atom, write a single byte value to memory address a.
If x is a sequence, write a sequence of byte values to consecutive memory
locations starting at location a.
Comments:
The lower 8-bits of each BYTE value, i.e. remainder(x, 256), is actually stored
in memory.

I believe that the word that I have put in all caps should eliminated or that
the words "sequence element" should be put in place of "byte value".

Of course, providing real structures that actually map the C structures
would get rid of the need for peeking and poking these values entirely.

Everett L.(Rett) Williams
rett at gvtc.com

Everett L.(Rett) Williams
rett at gvtc.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu