Re: Problems with C floats
- Posted by irv Jan 30, 2010
- 2484 views
For a test, in the demos there's callc.exu - copying the last test, and changing the C_DOUBLE to a C_FLOAT, we have this code:
puts(1, "\n> printf test:\n") s = define_c_proc(libc, "printf", {C_POINTER, C_INT, C_DOUBLE, C_INT, C_DOUBLE}) format = allocate_string("Here are 4 numbers: %d, %.3f, %d, %e\n") c_proc(s, {format, 111, 222.222, 333, 444.4444}) puts(1, "\n> printf test:\n") s = define_c_proc(libc, "printf", {C_POINTER, C_INT, C_DOUBLE, C_INT, C_FLOAT}) format = allocate_string("Here are 4 numbers: %d, %.3f, %d, %e\n") c_proc(s, {format, 111, 222.222, 333, 444.4444})
and get this printed:
> printf test: Here are 4 numbers: 111, 222.222, 333, 4.444444e+02 > printf test: Here are 4 numbers: 111, 222.222, 333, 1.332670e-269
Now, I may be doing something foolishly wrong, but the results I'm getting from my GTK programs indicate that something isn't getting through properly, and it only happens when C_FLOATs are involved.