Change Floating Point Precision - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Prolific Programmers (https://staging.qb64phoenix.com/forumdisplay.php?fid=26) +---- Forum: SMcNeill (https://staging.qb64phoenix.com/forumdisplay.php?fid=29) +---- Thread: Change Floating Point Precision (/showthread.php?tid=67) |
Change Floating Point Precision - SMcNeill - 04-20-2022 A quick example of how to change floating point precision in QB64. This swaps between quick math (which uses hardware math processors) to extended precision math (which uses software processing). Note that the default qbfpu is quite a bit faster, and for most folks this should be more than sufficient for your needs, as it tracks precision down to about the 15th decimal point. IF, however, you absolutely have to have greater levels of precision, you can now swap over to extended precision and have about 20 decimal points worth of precision, at a significant reduction of speed. And, if you need more than 20 decimal points of precision, you're just shit out of luck. Find a math library for that, or else write a string math handling routine -- your CPU isn't equipped to handle anything more than this, natively. FPU_Precision.h Code: (Select All) void set_dpfpu() { unsigned int mode = 0x37F; asm ("fldcw %0" : : "m" (*&mode));} QB64 Code: Code: (Select All) ' FPU_Precision.h needs to be in QB64 folder |