PROFESSIONAL NEWSGROUPS
WINDEV
,
WEBDEV
and
WINDEV Mobile
Home
|
Recent messages
|
Connect
|
Sign out
|
English
Home
→
WINDEV 2024
→
SIN(360) <>0 .... wrong value ???
SIN(360) <>0 .... wrong value ???
Started by BALTASAR, Jan., 03 2020 12:05 PM - 4 replies
Connect yourself…
BALTASAR
#1
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.
Report
0
0
Argus
#2
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.
Report
0
0
BALTASAR
#3
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
Report
0
0
Tim
#4
Posted on January, 22 2020 - 2:03 PM
mo
Resultaat
est un monétaire
=
Sin
(
360
)
Trace
(
mo
Resultaat
)
Report
0
0
BALTASAR
#5
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
Report
0
0
→ Go back to WINDEV 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (earlier versions)
Français
English
Español
Portuguesa
Close this window
Search type
Only topics
All the messages
Search period
Any time
Past hour
Past 24 hours
Past week
Past month
Past year
Cancel
Preview of your message
Adding an image
Import an image from a URL
Send an image from a file of your disk
Drop a file or click "Browse..."
or
Cancel
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Text