BeginComment:
This program demonstrates the math integer functions.

Copyright © 2020 Richard Lesh.  All rights reserved.
EndComment

#Pragma: UseUnicode

BeginProgram: Math2

BeginMain:
	ScalarDecl: const <int> a = 5
	ScalarDecl: const <int> b = 10
	ScalarDecl: const <int> c = -2

	Comment: abs, floor, ceil, round, trunc, min, max
	PrintLine: format("abs({0:d}) = {1:d}", a, abs(a))
	PrintLine: format("abs({0:d}) = {1:d}", c, abs(c))
	PrintLine: format("min({0:d}, {1:d}) = {2:d}", a, b, min(a,b))
	PrintLine: format("max({0:d}, {1:d}) = {2:d}", a, b, max(a,b))
	PrintLine: format("min({0:d}, {1:d}) = {2:d}", b, c, min(b,c))
	PrintLine: format("max({0:d}, {1:d}) = {2:d}", b, c, max(b,c))

	Comment: random numbers
	Expression: srand()
	PrintLine: format("random({0:d}) = {1:d}", a, irandom(a))
	PrintLine: format("random({0:d}) = {1:d}", a, irandom(a))
	PrintLine: format("random({0:d}) = {1:d}", a, irandom(a))
	PrintLine: format("random({0:d}) = {1:d}", a, irandom(a))
	PrintLine: format("random({0:d}) = {1:d}", a, irandom(a))
	PrintLine: format("random({0:d}) = {1:d}", b, irandom(b))
	PrintLine: format("random({0:d}) = {1:d}", b, irandom(b))
	PrintLine: format("random({0:d}) = {1:d}", b, irandom(b))
	PrintLine: format("random({0:d}) = {1:d}", b, irandom(b))
	PrintLine: format("random({0:d}) = {1:d}", b, irandom(b))
	PrintLine: format("random(2) = {0:d}", irandom(2))
	PrintLine: format("random(2) = {0:d}", irandom(2))
	PrintLine: format("random(2) = {0:d}", irandom(2))
	PrintLine: format("random(2) = {0:d}", irandom(2))
	PrintLine: format("random(2) = {0:d}", irandom(2))
	PrintLine: format("random() = {0:f}", random())
	PrintLine: format("random() = {0:f}", random())
	PrintLine: format("random() = {0:f}", random())
	PrintLine: format("random() = {0:f}", random())
	PrintLine: format("random() = {0:f}", random())
EndMain
EndProgram
