Generalised floating point multiplication: Difference between revisions
Generalised floating point multiplication (view source)
Revision as of 14:01, 7 December 2023
, 6 months ago→{{header|Wren}}: Minor tidy
(Added Wren) |
m (→{{header|Wren}}: Minor tidy) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 58:
{{works with|ALGOL 68G|Any - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-2.3.3 algol68g-2.3.3].}}
{{wont work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d] - due to extensive use of '''format'''[ted] ''transput''.}}
'''File: Template.Big_float.Multiplication.a68'''<
# TASK CODE #
# Actual generic mulitplication operator #
Line 116:
OP *:= = (REF DIGITS lhs, DIGIT arg)DIGITS: lhs := lhs * INITDIGITS arg;
</
################################################################
Line 151:
OD;
out SHR (UPB s-point)
);</
####################################################################
# A program to test arbitrary length floating point multiplication #
Line 200:
printf($l$)
OD
)</
<pre>
a = +523.23914037494284407864655 +-0++0+.+-0++0+
Line 241:
{{trans|Phix}}
In the interests of brevity many of the comments and all of the commented-out code has been omitted.
<
import (
Line 796:
test("septemvigesimal", septemVigesimal)
multTable()
}</
{{out}}
Line 883:
=={{header|Julia}}==
<
import Base.BigInt, Base.BigFloat, Base.print, Base.+, Base.-, Base.*
Line 1,051:
code_reuse_task(BalancedTernary)
</
<pre>
a = +-0++0+.+-0++0+ = 523.23914
Line 1,099:
0.1 accurate to several million decimal places, but just never quite exact.
<!--<
<span style="color: #000080;font-style:italic;">-- demo\rosetta\Generic_multiplication.exw</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">MAX_DP</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">81</span>
Line 1,562:
<span style="color: #000000;">test</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"hexadecimal"</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">hexadecimal</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">test</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"septemvigesimal"</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">septemvigesimal</span><span style="color: #0000FF;">)</span>
<!--</
The printed decimal output is inherently limited to IEEE 754 precision, hence I deliberately limited output (%.16g)
because it is silly to try and go any higher, whereas the output from b_mul() is actually perfectly accurate,
Line 1,620:
=== multiplication table ===
Without e notation, with hexadecimal across, septemvigesimal down, and balanced ternary contents!
<!--<
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"* |"</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">j</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #000000;">12</span> <span style="color: #008080;">do</span>
Line 1,639:
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"\n"</span><span style="color: #0000FF;">)</span>
<!--</
{{out}}
<pre>
Line 1,674:
=={{header|Wren}}==
{{trans|Phix}}
{{libheader|Wren-str}}
Via the Go entry.▼
{{libheader|Wren-iterate}}
<lang ecmascript>import "/str" for Str▼
{{libheader|Wren-fmt}}
import "/trait" for Stepped▼
import "/fmt" for Fmt▼
▲import "./fmt" for Fmt
var maxdp = 81
Line 2,157 ⟶ 2,160:
test.call("hexadecimal", hexadecimal)
test.call("septemvigesimal", septemVigesimal)
multTable.call()</
{{out}}
|