[Gambas-user] Sin(Rad(180)) = ?
Roberto Premoli
roberto.premoli at tiscali.it
Fri Apr 16 16:24:27 CEST 2021
On 16/04/21 16:00, vuott--- via User wrote:
> Hello,
> excuse me, if I'm not mistaken, the sine of 180° = 0.
>
> https://en.wikipedia.org/wiki/Sine#Properties_relating_to_the_quadrants
> <https://en.wikipedia.org/wiki/Sine#Properties_relating_to_the_quadrants>
>
> But in Gambas with this:
>
> Sin(Rad(180.0)) I obtain: 1.22464679914735E-16
>
> Why ?
>
> Regards
>
roundig error due to NOT ifinite precision of math processor.
do as follow:
parameter = 1000000
sine = (Int(parameter*Sin(Rad(180.0)))/parameter
this will workaround the problem.
tune "parameter" to fix precision in calculation
More information about the User
mailing list