Old 09-06-2018, 02:23 PM   #1
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: Holland
Posts: 2,904
Default JSFX: Imprecise $phi value

In JSFX the $phi constant seems to have "only" 9 decimals, but for it to be precise at 64-bit double floating point it would need 17 decimals.

Code:
desc:what the phi?!

@init

y1 = $phi; // 1.61803399
x1 = sqr(y1 * 2 - 1); // Not exactly 5

y2 = (sqrt(5) + 1) / 2;
x2 = sqr(y2 * 2 - 1); // 5

y3 = 1.6180339887498948;
x3 = sqr(y3 * 2 - 1); // 5

@gfx

gfx_x = gfx_y = 8;
gfx_a = gfx_r = 1; gfx_g = gfx_b = 0;
gfx_printf("%1.16e %1.16e\n", y1, x1); gfx_y += 2;
gfx_r = 0; gfx_g = 1;
gfx_printf("%1.16e %1.16e\n", y2, x2); gfx_y += 2;
gfx_printf("%1.16e %1.16e\n", y3, x3); gfx_y += 2;
Tested in REAPER 5.9x i386 and x86-64 on macOS 10.13.

Not at all important of course, but now that I know: It itches.
Tale is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.