Search code examples
floating-pointprecisionmaxscript

MAXScript: write numbers to file in full precision?


I'm looking for a way to make 3ds Max to write values to a file in their full precision?
I realize Max uses 32 bit floats in its internal representations but the values it outputs to files usually seem to be of slightly lower precision.

The only function that seem to be able to write values to a file is format "%" value to: f this function outputs values that look like 0.48729
I'm using this converter to check the float representation of this number and see that in hex it is 0x3ef97e13 if I try to play with its least significant digits I can get
0.487291 = 0x3ef97e35
0.487292 = 0x3ef97e56
0.487293 = 0x3ef97e78
so clearly, even the 32 bit number Max holds has more accuracy than what it outputs using this function.

The only reference I found for a better precision is to use formattedprint but that function doesn't seem to be able to write to a file.

Is there any other way?


Solution

  • Feed the output of formattedPrint to format or print (depending on your use-case).