Maths Functions Example

This is a small program showing the various maths functions in Octagon.



Maths Functions Program Example


prog_vars =

d/a 10 -- integer var set to 10

d/b 100 -- integer var set to 100

d/c -3.141 -- float var set to -3.141

d/result 0.0 -- float to hold total


prog_start =

print "Maths Example Program no 1"


prog_loop =

-- Display system var /pi

print "Pi is /pi"

add /a /b /c -> /result -- Add some numbers

print "adding /a /b /c = /result"

-- Set new value of /c

/c 1.5

-- Subtract some numbers

sub /a /b /c -> /result

print "subtracting /a /b /c = /result"

-- Multiply some numbers

mul /a /b /c -> /result

print "multiplying /a /b /c = /result"

-- Divide some numbers

div /a /b /c -> /result

print "dividing /a /b /c = /result"

-- Root of pi

sqrt /pi -> /result

print "root of pi is /result"

-- New Values

/a 25|/b 50|/c 100.0

-- Average of some numbers

ave /a /b /c -> /result

print "ave /a /b /c = /result"

-- Analyse some numbers

min /a /b /c -> /result

print "min of /a /b /c is /result"

max /a /b /c -> /result

print "max of /a /b /c is /result"

-- Hash of pi

hash /pi -> /result

-- Get a random number between 0 and 1000

rand 0 1000 -> /result

print "Random number /result"

print "Done exiting now!"



prog_stop =