I thought about it a little more...
I think, #Null would be a practicable result for an Error,
1. it's #False
2. only 0 as Base can cause 0 as Result, that can be easily checked before calling.
also, I tested overflow with <1, because also 0 can be an overflow.
all the rest, including the Sign check, remains the same.
Code: Select all
Procedure.q PowQ(Number.q, Exponent.q)
  Protected Result.q = Number ; Buffer Base to use as result for Exp.=1
  Protected Sign.l = 1        ; default sign for Result is +
  If Exponent = 2             ; for Exp.2
    Result * Number           ; spare Loop
  ElseIf Exponent > 2
    If Number < 0             ; Negative Base?
      Result = -Result        ; calculate with
      Number = -Number        ; Abs. Value
      If Exponent % 2         ; for odd Exponents
        Sign = -1             ; Buffer neg. Sign
      EndIf
    EndIf
    For i = 2 To Exponent     ; Loop for Exp.>2
      Result * Number
      If Result < 1           ; Check for numerical overflow
        ProcedureReturn 0   ; #False is Errorcode
      EndIf
    Next
    Result * Sign             ; sign Result
  ElseIf Exponent = 0         ; for Exp.=0
    Result = 1                ; no Calculation needed
  ElseIf Exponent < 0         ; for neg.Exp.
    Result = 0                ; #False is Errorcode
  EndIf
  ProcedureReturn Result
EndProcedure
 
			
			
									
									oh... and have a nice day.