(PB 5.73 LTS, PB 6.00 Alpha 3)
_________________________
For functions like Sin() and Cos() the documentation writes:
However, large numbers generate strange results, which look like that the argument is just passed through:Return value
Returns the sine of the angle. The result will be between -1.0 and 1.0.
(I know the numbers can not be correct for such high numbers, but the result should between -1.0 and 1.0)
Code: Select all
Debug Sin(1.0e18) ; -0.99281610405300347
Debug Sin(1.0e19) ; 10000000000000000000.0 Why? Should be between -1 and 1
Debug Cos(1.0e18) ; 0.11965025504785125
Debug Cos(1.0e19) ; 10000000000000000000.0 Why? Should be between -1 and 1
Debug Tan(1.0e18) ; -8.2976513811520967
Debug Tan(1.0e19) ; NaN Why?
For functions like ACosH, ASinH, and ATanH, the result is Infinity or 0.0 even if the result can be represented by a double:
Code: Select all
Debug ACosH(1.0e154) ; 355.29125150164299
Debug ACosH(1.0e155) ; +Infinity Why? Should be 357.59383659463703 = Log(2)+Log(1.0e155)
Debug ASinH(1.0e154) ; 355.29125150164299
Debug ASinH(1.0e155) ; +Infinity Why? Should be 357.59383659463703 = Log(2)+Log(1.0e155)
Debug ASinH(1.0e8) ; 19.113827924512311
Debug ASinH(-1.0e8) ; -Infinity Why? Should be -19.113827924512311
Debug StrD(ASinH(1.0e-15), 30) ; 0.000000000000001110223024625156
Debug StrD(ASinH(1.0e-16), 30) ; 0.000000000000000000000000000000 Why exact 0.0? Should be 1.0e-16 = 0.0000000000000001...
Debug StrD(ATanH(1.0e-16), 30) ; 0.000000000000000111022302462516
Debug StrD(ATanH(1.0e-17), 30) ; 0.000000000000000000000000000000 Why exact 0.0? Should be 1.0e-17 = 0.00000000000000001...
Both categories can be solved by using a private procedure, but it would be good to avoid such bypass.
Code: Select all
Procedure.d MySin(Value.d)
ProcedureReturn Sin(Mod(Value, 2*#PI))
EndProcedure
Define Ten.i, Value.d
For Ten = 0 To 30
Value = Pow(10, Ten)
Debug RSet(StrD(Sin(Value)), 35) + RSet(StrD(MySin(Value)), 35)
Next
Code: Select all
Procedure.d MyASinH(Value.d)
If Abs(Value) > 1.0e154
ProcedureReturn 0.6931471805599453094 + Log(Abs(Value))
ElseIf Abs(Value) < 1.0e-4
ProcedureReturn Value - Value*Value*Value/6.0
ElseIf Abs(Value) < 1.0e-3
ProcedureReturn Value - Value*Value*Value/6.0 + Value*Value*Value*Value*Value*3.0/40.0
EndIf
ProcedureReturn Sign(Value) * ASinH(Abs(Value))
EndProcedure
Define Ten.i, Value.d
For Ten = 0 To -20 Step -1
Value = Pow(10, Ten)
Debug RSet(StrD(ASinH(Value),30), 35) + RSet(StrD(MyASinH(Value),30), 35)
Next
For Ten = 0 To 12
Value = - Pow(10, Ten)
Debug RSet(StrD(ASinH(Value)), 35) + RSet(StrD(MyASinH(Value)), 35)
Next
For Ten = 150 To 160
Value = Pow(10, Ten)
Debug RSet(StrD(ASinH(Value)), 35) + RSet(StrD(MyASinH(Value)), 35)
Next