What I really need to do is to export a floating point number to C with no precision loss.
I did this in python:
import math
import struct
x = math.s
repr() is your friend.
C:\junk\es2>type es2.c
#include
#include
#include
int main(int argc, char** argv) {
double expected, actual;
int nconv;
expected = sqrt(2.0);
printf("expected: %20.17g\n", expected);
actual = -666.666;
nconv = scanf("%lf", &actual);
assert(nconv == 1);
printf("actual: %20.17g\n", actual);
assert(actual == expected);
return 0;
}
C:\junk\es2>gcc es2.c
C:\junk\es2>\python26\python -c "import math; print repr(math.sqrt(2.0))" | a
expected: 1.4142135623730951
actual: 1.4142135623730951
C:\junk\es2>