|
| SIN(360) <>0 .... wrong value ??? |
| Iniciado por BALTASAR, 03,ene. 2020 12:05 - 4 respuestas |
| |
| | | |
|
| |
Miembro registrado 52 mensajes |
|
| Publicado el 03,enero 2020 - 12:05 |
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. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 03,enero 2020 - 15:58 |
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. |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 52 mensajes |
|
| Publicado el 08,enero 2020 - 10:39 |
MyNumeric is numeric = 360 Trace(Sin(mynumeric))
result: -0.0000000000000002449293598295
still wrong |
| |
| |
| | | |
|
| | |
| |
| Publicado el 22,enero 2020 - 14:03 |
moResultaat est un monétaire = Sin(360) Trace(moResultaat) |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 52 mensajes |
|
| Publicado el 22,enero 2020 - 15:32 |
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 |
| |
| |
| | | |
|
| | | | |
| | |
|