Balanced ternary: Difference between revisions

Content added Content deleted
m (syntax highlighting fixup automation)
Line 29:
{{trans|Python}}
 
<langsyntaxhighlight lang=11l>F py_idiv(a, b)
I a >= 0
R a I/ b
Line 119:
 
V r = a * (b - c)
print(‘a * (b - c): ’r.to_int()‘ ’r)</langsyntaxhighlight>
 
{{out}}
Line 131:
=={{header|Ada}}==
Specifications (bt.ads):
<langsyntaxhighlight lang=Ada>with Ada.Finalization;
 
package BT is
Line 177:
procedure Finalize (Object : in out Balanced_Ternary);
end BT;</langsyntaxhighlight>
 
Implementation (bt.adb):
<langsyntaxhighlight lang=Ada>with Ada.Unchecked_Deallocation;
 
package body BT is
Line 360:
end Initialize;
 
end BT;</langsyntaxhighlight>
 
Test task requirements (testbt.adb):
<langsyntaxhighlight lang=Ada>with Ada.Text_Io; use Ada.Text_Io;
with Ada.Integer_Text_Io; use Ada.Integer_Text_Io;
with BT; use BT;
Line 381:
Put("a * (b - c) = "); Put(To_integer(Result), 4);
Put_Line (" " & To_String(Result));
end TestBT;</langsyntaxhighlight>
Output:
<pre>
Line 399:
To demonstrate the possibility, the ''integerFromBT'' and ''negateBT'' handlers here work by being tricksy with the characters' Unicode numbers. It's a more efficient way to deal with the characters. But I'm not sure how this'll be taken ''vis-à-vis'' not converting to native integers first, so the remaining handlers use a strictly if-then string comparison approach. Applescript's quite happy to convert automatically between integers, reals, numeric strings, and single-item lists containing numbers, so ''BTFromInteger'' accepts any of these forms, but the numbers represented must be whole-number values and must be small enough not to error AppleScript's ''as integer'' coercion. This coercion is error free for numbers in the range -(2 ^ 31) to 2 ^ 31 - 1, although actual integer class objects can only represent numbers in the range -(2 ^ 29) to 2 ^ 29 - 1. ''IntegerFromBT'' doesn't currently impose any integer-class size limit on its output.
 
<langsyntaxhighlight lang=applescript>-- Build a balanced ternary, as text, from an integer value or acceptable AppleScript substitute.
on BTFromInteger(n)
try
Line 566:
set line4 to "a * (b - c) = " & it & " or " & my integerFromBT(it)
 
return line1 & linefeed & line2 & linefeed & line3 & linefeed & line4</langsyntaxhighlight>
 
{{output}}
<langsyntaxhighlight lang=applescript>"a = 523
b = -436
c = 65
a * (b - c) = ----0+--0++0 or -262023"</langsyntaxhighlight>
 
=={{header|ATS}}==
<langsyntaxhighlight lang=ATS>
(*
** This one is
Line 789:
//
} (* end of [main0] *)
</syntaxhighlight>
</lang>
Output:
<pre>
Line 799:
 
=={{header|AutoHotkey}}==
<langsyntaxhighlight lang=AutoHotkey>BalancedTernary(n){
k = 0
if abs(n)<2
Line 820:
}
return r
}</langsyntaxhighlight>
Examples:<langsyntaxhighlight lang=AutoHotkey>data =
(
523
Line 831:
result .= A_LoopField " : " BalancedTernary(A_LoopField) "`n"
MsgBox % result
return</langsyntaxhighlight>
Outputs:<pre>
523 : +-0++0+
Line 840:
=={{header|C}}==
{{trans|Perl}}
<langsyntaxhighlight lang=c>#include <stdio.h>
#include <string.h>
 
Line 1,041:
 
return 0;
}</langsyntaxhighlight>
{{out}}
<pre> a: +-0++0+ 523
Line 1,049:
 
=={{header|C sharp|C#}}==
<langsyntaxhighlight lang=csharp>using System;
using System.Text;
using System.Collections.Generic;
Line 1,279:
return result;
}
}</langsyntaxhighlight>
output:
<pre>a: +-0++0+ = 523
Line 1,287:
 
=={{header|C++}}==
<langsyntaxhighlight lang=cpp>#include <iostream>
#include <string>
#include <climits>
Line 1,499:
return 0;
}
</syntaxhighlight>
</lang>
 
Output
Line 1,511:
 
=={{header|Common Lisp}}==
<langsyntaxhighlight lang=lisp>;;; balanced ternary
;;; represented as a list of 0, 1 or -1s, with least significant digit first
Line 1,603:
(bt-integer b) (bt-string b)
(bt-integer c) (bt-string c)
(bt-integer d) (bt-string d)))</langsyntaxhighlight>output<syntaxhighlight lang=text>a 523 +-0++0+
b -436 -++-0--
c 65 +-++-
a × (b − c) = -262023 ----0+--0++0</langsyntaxhighlight>
 
=={{header|D}}==
{{trans|Python}}
<langsyntaxhighlight lang=d>import std.stdio, std.bigint, std.range, std.algorithm;
 
struct BalancedTernary {
Line 1,753:
const /*immutable*/ r = a * (b - c);
writeln("a * (b - c): ", r.toBint, ' ', r);
}</langsyntaxhighlight>
{{out}}
<pre>a: 523 +-0++0+
Line 1,762:
=={{header|Elixir}}==
{{trans|Erlang}}
<langsyntaxhighlight lang=elixir>defmodule Ternary do
def to_string(t), do: ( for x <- t, do: to_char(x) ) |> List.to_string
Line 1,835:
IO.puts "b = #{bs} -> #{b}"
IO.puts "c = #{cs} -> #{c}"
IO.puts "a x (b - c) = #{rs} -> #{r}"</langsyntaxhighlight>
 
{{out}}
Line 1,846:
 
=={{header|Erlang}}==
<langsyntaxhighlight lang=erlang>
-module(ternary).
-compile(export_all).
Line 1,936:
add_util(1) -> [0,1];
add_util(0) -> [0,0].
</syntaxhighlight>
</lang>
'''Output'''
<langsyntaxhighlight lang=erlang>
234> ternary:test().
A = +-0++0+ -> 523
Line 1,945:
A x (B - C) = 0----0+--0++0 -> -262023
ok
</syntaxhighlight>
</lang>
 
 
Line 1,953:
{{trans|Common Lisp}}
{{works with|Factor|0.98}}
<langsyntaxhighlight lang=factor>USING: kernel combinators locals formatting lint literals
sequences assocs strings arrays
math math.functions math.order ;
Line 2,015:
"c" c bt>integer c bt>string "%s: %d, %s\n" printf
"a*(b-c)" d bt>integer d bt>string "%s: %d, %s\n" printf
]</langsyntaxhighlight>
<syntaxhighlight lang=text>a: 523, +-0++0+
b: -436, -++-0--
c: 65, +-++-
a*(b-c): -262023, ----0+--0++0</langsyntaxhighlight>
 
=={{header|FreeBASIC}}==
{{trans|Liberty BASIC}}
<langsyntaxhighlight lang=freebasic>
#define MAX(a, b) iif((a) > (b), (a), (b))
Dim Shared As Integer pow, signo
Line 2,151:
Print "a*(b-c): ", a * (b - c)
Sleep
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 2,280:
</pre>
'''A crude English/Pidgin Algol translation of the above [[:Category:Glagol]] code.'''
<langsyntaxhighlight lang=algol68>PROGRAM Setun+;
USES
Parameter IS "...\Departments\Exchange\"
Line 2,392:
Output.ChTarget(" = %d.", InNumber(), 0, 0, 0);
Remove.Memory
END Setun.</langsyntaxhighlight>
 
=={{header|Go}}==
<langsyntaxhighlight lang=go>package main
 
import (
Line 2,618:
fmt.Println("int overflow")
}
}</langsyntaxhighlight>
{{out}}
<pre>
Line 2,629:
=={{header|Groovy}}==
Solution:
<langsyntaxhighlight lang=groovy>enum T {
m('-', -1), z('0', 0), p('+', 1)
 
Line 2,788:
 
String toString() { value }
}</langsyntaxhighlight>
 
Test:
<langsyntaxhighlight lang=groovy>BalancedTernaryInteger a = new BalancedTernaryInteger('+-0++0+')
BalancedTernaryInteger b = new BalancedTernaryInteger(-436)
BalancedTernaryInteger c = new BalancedTernaryInteger(T.p, T.m, T.p, T.p, T.m)
Line 2,806:
 
println "\nDemonstrate failure:"
assert (a * (b-c)) == a</langsyntaxhighlight>
 
Output:
Line 2,831:
=={{header|Haskell}}==
BTs are represented internally as lists of digits in integers from -1 to 1, but displayed as "+-0" strings.
<langsyntaxhighlight lang=haskell>data BalancedTernary = Bt [Int]
 
zeroTrim a = if null s then [0] else s where
Line 2,888:
print $ map btInt [a,b,c]
print $ r
print $ btInt r</langsyntaxhighlight>
 
=={{header|Icon}} and {{header|Unicon}}==
Line 2,895:
 
Works in both languages:
<langsyntaxhighlight lang=unicon>procedure main()
a := "+-0++0+"
write("a = +-0++0+"," = ",cvtFromBT("+-0++0+"))
Line 2,984:
}
return (\negate,map(mul,"+-","-+")) | mul
end</langsyntaxhighlight>
 
Output:
Line 3,000:
Implementation:
 
<langsyntaxhighlight lang=j>trigits=: 1+3 <.@^. 2 * 1&>.@|
trinOfN=: |.@((_1 + ] #: #.&1@] + [) #&3@trigits) :. nOfTrin
nOfTrin=: p.&3 :. trinOfN
Line 3,011:
add=: carry@(+/@,:)
neg=: -
mul=: trimLead0@carry@(+//.@(*/))</langsyntaxhighlight>
 
trinary numbers are represented as a sequence of polynomial coefficients. The coefficient values are limited to 1, 0, and -1. The polynomial's "variable" will always be 3 (which happens to illustrate an interesting absurdity in the terminology we use to describe polynomials -- one which might be an obstacle for learning, for some people).
Line 3,029:
Definitions for example:
 
<langsyntaxhighlight lang=j>a=: trinOfStr '+-0++0+'
b=: trinOfN -436
c=: trinOfStr '+-++-'</langsyntaxhighlight>
 
Required example:
 
<langsyntaxhighlight lang=j> nOfTrin&> a;b;c
523 _436 65
 
Line 3,041:
----0+--0++0
nOfTrin a mul b (add -) c
_262023</langsyntaxhighlight>
 
=={{header|Java}}==
<langsyntaxhighlight lang=java>
/*
* Test case
Line 3,256:
}
}
</syntaxhighlight>
</lang>
 
Output:
Line 3,271:
{{trans|Python}}
 
<langsyntaxhighlight lang=julia>struct BalancedTernary <: Signed
digits::Vector{Int8}
end
Line 3,355:
println("a * (b - c): $(Int(r)), $r")
 
@assert Int(r) == Int(a) * (Int(b) - Int(c))</langsyntaxhighlight>
 
{{out}}
Line 3,365:
=={{header|Kotlin}}==
This is based on the Java entry. However, I've added 'BigInteger' support as this is a current requirement of the task description even though it's not actually needed to process the test case:
<langsyntaxhighlight lang=scala>// version 1.1.3
 
import java.math.BigInteger
Line 3,508:
val iResult = bResult.toBigInteger()
println("a * (b - c) = $bResult = $iResult")
}</langsyntaxhighlight>
 
{{out}}
Line 3,519:
 
=={{header|Liberty BASIC}}==
<syntaxhighlight lang=lb>
<lang lb>
global tt$
tt$="-0+" '-1 0 1; +2 -> 1 2 3, instr
Line 3,657:
wend
end function
</syntaxhighlight>
</lang>
 
{{out}}
Line 3,672:
=={{header|Lua}}==
{{trans|C}}
<langsyntaxhighlight lang=lua>function to_bt(n)
local d = { '0', '+', '-' }
local v = { 0, 1, -1 }
Line 3,817:
end
 
main()</langsyntaxhighlight>
{{out}}
<pre> a: +-0++0+ 523
Line 3,825:
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<langsyntaxhighlight lang=mathematica>frombt = FromDigits[StringCases[#, {"+" -> 1, "-" -> -1, "0" -> 0}],
3] &;
tobt = If[Quotient[#, 3, -1] == 0,
Line 3,846:
btnegate@#1],
If[StringLength@#2 == 1,
"0", #0[#1, StringDrop[#2, -1]] <> "0"]] &;</langsyntaxhighlight>
Examples:
<langsyntaxhighlight lang=mathematica>frombt[a = "+-0++0+"]
b = tobt@-436
frombt[c = "+-++-"]
btmultiply[a, btsubtract[b, c]]</langsyntaxhighlight>
Outputs:
<pre>523
Line 3,863:
=={{header|МК-61/52}}==
{{trans|Glagol}}
<langsyntaxhighlight lang=mk-61>ЗН П2 Вx |x| П0 0 П3 П4 1 П5
ИП0 /-/ x<0 80
ИП0 ^ ^ 3 / [x] П0 3 * - П1
Line 3,874:
ИП2 /-/ ПП 88 1 П3 БП 10
ИП3 x#0 86 ИП2 ПП 88 ИП4 С/П
8 + ИП5 * ИП4 + П4 ИП5 1 0 * П5 В/О</langsyntaxhighlight>
 
''Note: the "-", "0", "+" denotes by digits, respectively, the "7", "8", "9".''
 
=={{header|Nim}}==
<langsyntaxhighlight lang=Nim>import strformat
import tables
 
Line 4,056:
echo "a × (b - c):"
echo fmt"– in ternary: {x}"
echo fmt"– in decimal: {x.toInt}"</langsyntaxhighlight>
 
{{out}}
Line 4,074:
 
=={{header|OCaml}}==
<langsyntaxhighlight lang=ocaml>type btdigit = Pos | Zero | Neg
type btern = btdigit list
 
Line 4,125:
let _ =
Printf.printf "a = %d\nb = %d\nc = %d\na * (b - c) = %s = %d\n"
(to_int a) (to_int b) (to_int c) (to_string d) (to_int d);</langsyntaxhighlight>
Output:
<pre>a = 523
Line 4,133:
 
=={{header|Perl}}==
<langsyntaxhighlight lang=perl>use strict;
use warnings;
 
Line 4,207:
printf " c: %14s %10d\n", $c, from_bt( $c );
printf "a*(b-c): %14s %10d\n", $d, from_bt( $d );
</syntaxhighlight>
</lang>
{{out}}
<pre> a: +-0++0+ 523
Line 4,218:
Using strings to represent balanced ternary. Note that as implemented dec2bt and bt2dec are limited to Phix integers (~+/-1,000,000,000),
but it would probably be pretty trivial (albeit quite a bit slower) to replace them with (say) ba2bt and bt2ba which use/yield bigatoms.
<!--<langsyntaxhighlight lang=Phix>(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">bt2dec</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">bt</span><span style="color: #0000FF;">)</span>
Line 4,311:
<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;">"%7s: %12s %9d\n"</span><span style="color: #0000FF;">,{</span><span style="color: #008000;">"c"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">c</span><span style="color: #0000FF;">,</span><span style="color: #000000;">bt2dec</span><span style="color: #0000FF;">(</span><span style="color: #000000;">c</span><span style="color: #0000FF;">)})</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;">"%7s: %12s %9d\n"</span><span style="color: #0000FF;">,{</span><span style="color: #008000;">"a*(b-c)"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">res</span><span style="color: #0000FF;">,</span><span style="color: #000000;">bt2dec</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">)})</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 4,323:
show it manages a 5000+digit multiplication and subtraction in about 0.2s, which I say is "reasonable", given that I didn't try very hard,
as evidenced by that daft addition lookup table!
<!--<langsyntaxhighlight lang=Phix>(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #004080;">atom</span> <span style="color: #000000;">t0</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">time</span><span style="color: #0000FF;">()</span>
Line 4,341:
<span style="color: #008080;">end</span> <span style="color: #008080;">while</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;">"It took %d subtractions to reach 0. (%3.2fs)\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">count</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">time</span><span style="color: #0000FF;">()-</span><span style="color: #000000;">t0</span><span style="color: #0000FF;">})</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 4,349:
 
=={{header|PicoLisp}}==
<langsyntaxhighlight lang=PicoLisp>(seed (in "/dev/urandom" (rd 8)))
 
(setq *G '((0 -1) (1 -1) (-1 0) (0 0) (1 0) (-1 1) (0 1)))
Line 4,470:
(println 'R (trih R) R) )
 
(bye)</langsyntaxhighlight>
 
=={{header|Prolog}}==
Line 4,477:
'''The conversion.'''<br>
Library '''clpfd''' is used so that '''bt_convert''' works in both ways Decimal => Ternary and Ternary ==> Decimal.
<langsyntaxhighlight lang=Prolog>:- module('bt_convert.pl', [bt_convert/2,
op(950, xfx, btconv),
btconv/2]).
Line 4,544:
R1 #= R - 3 * C1, % C1 #= 1,
convert(N1, C1, [R1 | LC], LF).
</langsyntaxhighlight><br>
'''The addition.''' <br>
The same predicate is used for addition and substraction.
<langsyntaxhighlight lang=Prolog>:- module('bt_add.pl', [bt_add/3,
bt_add1/3,
op(900, xfx, btplus),
Line 4,670:
strip_nombre(L) -->
L.
</syntaxhighlight>
</lang>
'''The multiplication.''' <br>
We give a predicate '''euclide(?A, +B, ?Q, ?R)''' which computes both the multiplication and the division, but it is very inefficient.<br>
The predicates '''multiplication(+B, +Q, -A)''' and '''division(+A, +B, -Q, -R)''' are much more efficient.
<langsyntaxhighlight lang=Prolog>:- module('bt_mult.pl', [op(850, xfx, btmult),
btmult/2,
multiplication/3
Line 4,845:
; mult_(B, Q1, A1, R, Resultat, Ajout)) .
 
</syntaxhighlight>
</lang>
Example of output :
<pre> ?- A btconv "+-0++0+".
Line 4,864:
=={{header|Python}}==
{{trans|Common Lisp}}
<langsyntaxhighlight lang=python>class BalancedTernary:
# Represented as a list of 0, 1 or -1s, with least significant digit first.
 
Line 4,958:
print "a * (b - c):", r.to_int(), r
 
main()</langsyntaxhighlight>
{{out}}
<pre>a: 523 +-0++0+
Line 4,966:
 
=={{header|Racket}}==
<langsyntaxhighlight lang=racket>#lang racket
 
;; Represent a balanced-ternary number as a list of 0's, 1's and -1's.
Line 5,041:
[description (list 'a 'b 'c "a×(b−c)")])
(printf "~a = ~a or ~a\n" description (bt->integer bt) (bt->string bt))))
</syntaxhighlight>
</lang>
 
{{output}}
Line 5,054:
(formerly Perl 6)
{{Works with|rakudo|2017.01}}
<syntaxhighlight lang=raku perl6lines>class BT {
has @.coeff;
 
Line 5,116:
say 'b == ', $b.Int;
say 'c == ', $c.Int;
say "a × (b − c) == ", ~$x, ' == ', $x.Int;</langsyntaxhighlight>
{{out}}
<pre>a == 523
Line 5,125:
=={{header|REXX}}==
The REXX program could be optimized by using &nbsp; (procedure) with &nbsp; '''expose''' &nbsp; and having the &nbsp; <big>'''$.'''</big> &nbsp; and &nbsp; <big>'''@.'''</big> &nbsp; variables set only once.
<langsyntaxhighlight lang=rexx>/*REXX program converts decimal ◄───► balanced ternary; it also performs arithmetic. */
numeric digits 10000 /*be able to handle gihugic numbers. */
Ao = '+-0++0+' ; Abt = Ao /* [↓] 2 literals used by subroutine*/
Line 5,175:
btNorm: _= strip(arg(1), 'L', 0); if _=='' then _=0; return _ /*normalize the number.*/
btSub: return btAdd( arg(1), btNeg( arg(2) ) ) /*subtract two BT args.*/
btShow: say center( arg(1), 9) right( arg(2), 20) @@ right( bt2d(arg(2)), 9) @; return</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default input:}}
<pre>
Line 5,186:
 
=={{header|Ruby}}==
<langsyntaxhighlight lang=ruby>class BalancedTernary
include Comparable
def initialize(str = "")
Line 5,308:
val = eval(exp)
puts "%8s :%13s,%8d" % [exp, val, val.to_i]
end</langsyntaxhighlight>
 
{{out}}
Line 5,319:
 
=={{header|Rust}}==
<langsyntaxhighlight lang=rust>use std::{
cmp::min,
convert::{TryFrom, TryInto},
Line 5,576:
}
}
</syntaxhighlight>
</lang>
 
Output
Line 5,588:
=={{header|Scala}}==
This implementation represents ternaries as a reversed list of bits. Also, there are plenty of implicit convertors
<langsyntaxhighlight lang=scala>
object TernaryBit {
val P = TernaryBit(+1)
Line 5,675:
implicit def intToTernary(i: Int): Ternary = valueOf(i)
}
</syntaxhighlight>
</lang>
 
Then these classes can be used in the following way:
<langsyntaxhighlight lang=scala>
object Main {
 
Line 5,693:
 
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 5,703:
 
Besides, we can easily check, that the code works for any input. This can be achieved with ScalaCheck:
<langsyntaxhighlight lang=scala>
object TernarySpecification extends Properties("Ternary") {
 
Line 5,719:
 
}
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 5,729:
=={{header|Tcl}}==
This directly uses the printable representation of the balanced ternary numbers, as Tcl's string operations are reasonably efficient.
<langsyntaxhighlight lang=tcl>package require Tcl 8.5
 
proc bt-int b {
Line 5,785:
- { return [bt-sub $sub $b] }
}
}</langsyntaxhighlight>
Demonstration code:
<langsyntaxhighlight lang=tcl>for {set i 0} {$i<=10} {incr i} {puts "$i = [int-bt $i]"}
puts "'+-+'+'+--' = [bt-add +-+ +--] = [bt-int [bt-add +-+ +--]]"
puts "'++'*'++' = [bt-mul ++ ++] = [bt-int [bt-mul ++ ++]]"
Line 5,796:
puts "a = [bt-int $a], b = [bt-int $b], c = [bt-int $c]"
set abc [bt-mul $a [bt-sub $b $c]]
puts "a*(b-c) = $abc (== [bt-int $abc])"</langsyntaxhighlight>
Output:
<pre>
Line 5,818:
=={{header|Visual Basic .NET}}==
{{trans|C#}}
<langsyntaxhighlight lang=vbnet>Imports System.Text
 
Module Module1
Line 6,005:
End Class
 
End Module</langsyntaxhighlight>
{{out}}
<pre>a: +-0++0+ = 523
Line 6,016:
{{libheader|Wren-big}}
{{libheader|Wren-trait}}
<langsyntaxhighlight lang=ecmascript>import "/big" for BigInt
import "/trait" for Comparable
 
Line 6,140:
var bResult = a * (b - c)
var iResult = bResult.toBigInt
System.print("a * (b - c) = %(bResult) = %(iResult)")</langsyntaxhighlight>
 
{{out}}