Arbitrary-precision integers (included): Difference between revisions

(6 intermediate revisions by 4 users not shown)
Line 1,237:
 
=={{header|langur}}==
Arbitrary precision is native in langur.
<syntaxhighlight lang="langur">val .xs = toStringstring 5 ^ 4 ^ 3 ^ 2
 
writeln .len(.xs), " digits"
val .len = len .xs
 
writeln .len, " digits"
if len(.lenxs) > 39 and s2s(.xs, 1..20) == "62060698786608744707" and
s2s(.xs, .len-1920 .. .len-1) == "92256259918212890625" {
 
if .len > 39 and s2s(.xs, 1..20) == "62060698786608744707" and
s2s(.xs, .len-19 .. .len) == "92256259918212890625" {
writeln "SUCCESS"
}
Line 1,966 ⟶ 1,967:
{{works with|Rakudo|2022.07}}
 
<syntaxhighlight lang="raku" line>use Test;
given [**] 5, 4, 3, 2 {
ok ~([**] 5, 4, 3, 2) ~~ /^ '62060698786608744707' <digit>* '92256259918212890625' $/,
use Test;
'5**4**3**2 has expected first and last twenty digits';</syntaxhighlight>
ok ~([**] 5, 4, 3, 2) ~~ok /^ '62060698786608744707' <digit>* '92256259918212890625' $/,
'5**4**3**2 has expected first and last twenty digits';</syntaxhighlight>
printf 'This number has %d digits', .chars;
}</syntaxhighlight>
{{out}}
<pre>ok 1 - 5**4**3**2 has expected first and last twenty digits</pre>
This number has 183231 digits</pre>
 
=={{header|REXX}}==
Line 2,166 ⟶ 2,172:
 
=={{header|Sidef}}==
<syntaxhighlight lang="ruby">var x = 5**(4**(3**2));
var y = x.to_s;
printf("5**4**3**2 =  %s...%s and has  %i digits\n", y.ftfirst(0,1920), y.ftlast(-20), y.len);</syntaxhighlight>
{{out}}
<pre>
Line 2,498 ⟶ 2,504:
{{libheader|Wren-fmt}}
{{libheader|Wren-big}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
import "./big" for BigInt
 
var p = BigInt.three.pow(BigInt.two)
889

edits