Re: Passing floats/doubles to C

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

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

Yes, I finally noticed that I had poke4(material, atom_to_float64(1.0))
and then changed it to poke(material, atom_to_float64(1.0)). It didn't
matter, it still gives me incorrect values, well, after the 12th
member now.
 Even though now, since I use the poke(material, atom_to_float64(1.0))
instead of the poke(material, atom_to_float32(1.0)) like what I need,
I get these values set in the C structure members in the DLL:
[ in my c function: DllExport int SET_MATERIALS(LPMATERIAL material)]
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
54270830327981012000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000
0.000000
0.000000
0.000000
Just like if I use:DllExport int SET_MATERIALS(double material[17]), I
get those values.
 I set all the members to value of 1.0 in Euphoria and then after
it prints out the 12th member, it craps out on me. Why?

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

Search



Quick Links

User menu

Not signed in.

Misc Menu