Colin
> On 6 Oct 2019, at 11:34, Colin Holgate via use-livecode
> <[email protected]> wrote:
>
> Pi is a reserved work, so I used pie. I haven’t seen this way of producing Pi
> before, and in both JavaScript and LivceCode it seems to be instantaneous. I
> think it’s a rewording of 4*(1-1/3+1/5-1/7+1/9…)
…
> set numberformat to “x.xxxxxxxxxxxxxxxxxxxxxxx"
>
Your solution seems to be missing a few hundred thousand digits ;-) The
JavaScript solution prints the first 1,000,000 digits of Pi.
Actually, the article says that the script only can produce 1,000,000 digits
when run in a Chrome console. It will only print the first 315,633 digits in
Firefox. (I haven’t tried that to confirm it.)
...
> BTW, I haven’t seen JavaScript using ‘let’ before, or having ’n’ to indicate
> a floating point number. That could be a dot net thing.
“Let” was introduced into JavaScript some time ago. It provides block-level
scope. This console session may demonstrate the difference:
>>> j = 0;
0
>>> for (var j = 0; j < 10; j++) {};
>>> print(j);
10
>>> k = 0;
0
>>> for (let k = 0; k < 10; k++) {};
>>> print(k);
0
Big Integer support was recently introduced into JavaScript. The ’n’ suffix
denotes a Big Integer, “primitive” numbers are always floats in JavaScript.
Regards
Peter
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode