PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV 2024 → SIN(360) <>0  .... wrong value ???
SIN(360) <>0 .... wrong value ???
Started by BALTASAR, Jan., 03 2020 12:05 PM - 4 replies
Registered member
52 messages
Popularité : +3 (3 votes)
Posted on January, 03 2020 - 12:05 PM
I'm using many trigonometric formulas, then I see that windev fails with a few of them, for example

trace(SIN(360))

returns: -0.0000000000000002449293598295

I found that sin(modulo(myangle,360)) works fine but I don't trust in every other calculations.
Posted on January, 03 2020 - 3:58 PM
I haven't tested, but it looks like the usual "Real imprecision" problem.

If I'm right, do
MyNumeric is numeric = 360
trace(sin(mynumeric))

What is happening in my opinion is that the compiler is interpreting 360 as real, as you do not type the value. This is done this way for historical reasons (currenty and high precision numeric did not exist in old versions of the compiler, and changing this behavior would break existing code).

So any explicit number used in an expression/calculation is real by default... And reals, by construction and in ANY language, are not able to store every possible value, hence this kind of problem.

So the function is not in question.
Registered member
52 messages
Popularité : +3 (3 votes)
Posted on January, 08 2020 - 10:39 AM
MyNumeric is numeric = 360
Trace(Sin(mynumeric))


result: -0.0000000000000002449293598295

still wrong
Posted on January, 22 2020 - 2:03 PM
moResultaat est un monétaire = Sin(360)
Trace(moResultaat)
Registered member
52 messages
Popularité : +3 (3 votes)
Posted on January, 22 2020 - 3:32 PM
Thanks, Tim.

What I can't understand is that Windev says:

Currency: recommended type for the calculations performed on real values that require an absolute precision for the decimals, as currency values for example.
A currency manages 24 significant digits (up to 18 digits for the integer part and up to 6 digits for the decimal part). The precision is precise to 6 decimals.
For more details about the currencies.
Example: MyCurrency is currency

Numeric: recommended type for the calculations on real values that required an absolute precision for the decimals.
A numeric manages 38 significant digits (up to 32 digits for the integer part and up to 6 digits for the decimal part). The precision is precise to 6 decimals.
For more details about the numerics.
Example: MyCurrency is numeric