FORUMS PROFESSIONNELS
WINDEV
,
WEBDEV
et
WINDEV Mobile
Accueil
|
Messages récents
|
Connexion
|
Déconnexion
|
Français
Accueil
→
WINDEV 2024
→
SIN(360) <>0 .... wrong value ???
SIN(360) <>0 .... wrong value ???
Débuté par BALTASAR, 03 jan. 2020 12:05 - 4 réponses
Connectez-vous…
BALTASAR
#1
Membre enregistré
52 messages
Popularité : +3 (3 votes)
Posté le 03 janvier 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.
Signaler
0
0
Argus
#2
Posté le 03 janvier 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.
Signaler
0
0
BALTASAR
#3
Membre enregistré
52 messages
Popularité : +3 (3 votes)
Posté le 08 janvier 2020 - 10:39
MyNumeric
is
numeric
=
360
Trace
(
Sin
(
mynumeric
)
)
result: -0.0000000000000002449293598295
still wrong
Signaler
0
0
Tim
#4
Posté le 22 janvier 2020 - 14:03
mo
Resultaat
est un monétaire
=
Sin
(
360
)
Trace
(
mo
Resultaat
)
Signaler
0
0
BALTASAR
#5
Membre enregistré
52 messages
Popularité : +3 (3 votes)
Posté le 22 janvier 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
Signaler
0
0
→ Revenir à WINDEV 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (précédentes versions)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Type de recherche
Uniquement les sujets
Tous les messages
Période de recherche
Date indifférente
Moins d'une heure
Moins de 24 heures
Moins d'une semaine
Moins d'un mois
Moins d'un an
Annuler
Aperçu de votre message
Ajouter une image
Importer une image depuis une URL
Envoyer une image depuis un fichier de votre disque
Déposez ici un fichier ou cliquez sur "Parcourir..."
ou
Annuler
0%
WLangage
SQL
XML, HTML
JAVA, Javascript
Texte