You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// pi.per
//
// The number of digits we should calculate
var digits = 10000;
var i = 1;
var x = 3 * (10 ** (digits + 20));
var pi = x;
while (x > 0) {
x = x * i / ((i + 1) * 4);
pi += (x / (i + 2));
i += 2;
}
print(pi / (10 ** 20));
...gets compiled into this:
// Automatically generated code by Perlang 0.4.0-dev.20 at 2024-02-24T20:15:53.3599921Z// Do not modify. Changes to this file might be overwritten the next time the Perlang compiler is executed.
#include<math.h>// fmod()
#include<stdint.h>
#include"bigint.hpp"// BigInt
#include"stdlib.hpp"//// Method definitions//intmain();
//// Method declarations//intmain() {
int32_t digits = 10000;
int32_t i = 1;
BigInt x = (BigInt)3 * (perlang::BigInt_pow(10, (digits + 20)));
BigInt pi = x;
while (x > 0) {
x = x * (BigInt)i / ((i + 1) * 4);
pi = pi += (x / (i + 2));
i = i += 2;
}
;
perlang::print((pi / (perlang::BigInt_pow(10, 20))));
}
Note the pi = pi += (x / (i + 2)). Why on earth is this? It should be enough with just pi += (x / (i + 2)), I believe.
The text was updated successfully, but these errors were encountered:
Moved to GitLab
Please continue to the new version of this issue here: https://gitlab.perlang.org/perlang/perlang/-/issues/424. The GitHub page you are currently reading will not contain the latest information on this issue.
While working on finalizing #415, I saw something interesting. The following Perlang program (https://github.com/perlang-org/perlang/blob/52f7d7d303eba83fa3fe3bdb5e9725aa940dee0f/docs/examples/quickstart/pi.per):
...gets compiled into this:
Note the
pi = pi += (x / (i + 2))
. Why on earth is this? It should be enough with justpi += (x / (i + 2))
, I believe.The text was updated successfully, but these errors were encountered: