Procedure PGCD(a.l, b.l)
Protected c.l
If a And b
While b
c = a % b
a = b
b = c
Wend
If a < 0
a = - a
EndIf
Else
a = 0
EndIf
ProcedureReturn a
EndProcedure
Procedure PPCM(a.l, b.l)
Protected c.l
If a And b
c = a * b / PGCD(a, b)
If c < 0
c = - c
EndIf
EndIf
ProcedureReturn c
EndProcedure
Debug PGCD( 12, 15)
Debug PGCD( 12, - 15)
Debug PGCD(- 12, 15)
Debug PGCD(- 12, - 15)
Debug "---"
Debug PPCM( 12, 15)
Debug PPCM( 12, - 15)
Debug PPCM(- 12, 15)
Debug PPCM(- 12, - 15)
; - - - - - - - - - - - - - - - - - - - - - - - -
Procedure Sgn(x.l)
ProcedureReturn(x > 0 Or #False) -(x < 0 Or #False)
EndProcedure
Procedure SgnF(x.f)
ProcedureReturn(x > 0 Or #False) -(x < 0 Or #False)
EndProcedure
Debug Sgn(- 5)
Debug Sgn(- 0)
Debug Sgn( 5)
Debug SgnF(- 5.0)
Debug SgnF(- 0.0)
Debug SgnF( 5.0)