Look at the attached image: the same code in another application works perfectly, but here .... I just don't understand.
Danilo
If someone can explain it to me?
- softdevo@tiscali.it
- Posts: 191
- Joined: Wed Sep 30, 2015 1:30 pm
If someone can explain it to me?
- Attachments
-
- Immagine.jpg (83.99 KiB) Viewed 947 times
If someone can explain it to me?
Hi Danilo,
try using System.Decimal instead of System.Double.
see: https://www.xsharp.eu/forum/public-vo-v ... cimal#7418
Regards,
Stefan
try using System.Decimal instead of System.Double.
see: https://www.xsharp.eu/forum/public-vo-v ... cimal#7418
Regards,
Stefan
If someone can explain it to me?
Sorry, Danilo,
pls post bigger shots, this one is impossible to read.
Karl
pls post bigger shots, this one is impossible to read.
Karl
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
If someone can explain it to me?
Hi Danilo,
this is how real8 and floats work, and it is that way also in VO.
Look at your SetFloatDelta() setting in both applications.
Wolfgang
this is how real8 and floats work, and it is that way also in VO.
Look at your SetFloatDelta() setting in both applications.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
If someone can explain it to me?
Danilo
The reason for this boils down to rounding errors.
Computations in a digital computer are exact using a number base of 2.
Our understanding is based on a base of 10.
Any conversion will be slightly inaccurate.
To ensure total and absolute consistency in this process every calculation made must be rounded in the same way (up or down). Any compiler will do this in a consistent way.
The downside of this is that the rounding process takes time, and if we require total accuracy, must be done as part of each calculation. When there are thousands of such conversions/calculations to be done this mounts up.
As long as we are dealing with very small rounding errors we need not worry because they will never build up to such an extent as to have any noticeable effect on what we are trying to calculate.
For example, calculating an on-screen pixel position to 2 places of decimals would achieve little.
Floats are designed to calculate numerical results over a huge range, whilst not requiring the additional time-consuming overhead of base numbering scheme conversion.
Therefore, you should never use Floats in any situation where absolute comparisons/values may be required.
They do save time of course, when compared to decimal. It’s a case of “horses for courses”.
Terry
PS Having just read Wolfgang's reply I'm just guessing that SetFloatDelta() gives an accuracy limitation on Floats, allowing the compiler to do things to whatever accuracy is required.
So rather than saying never use Floats, I guess it should be "do not use floats unless SetFloatData() is set.
That is just a guess.
The reason for this boils down to rounding errors.
Computations in a digital computer are exact using a number base of 2.
Our understanding is based on a base of 10.
Any conversion will be slightly inaccurate.
To ensure total and absolute consistency in this process every calculation made must be rounded in the same way (up or down). Any compiler will do this in a consistent way.
The downside of this is that the rounding process takes time, and if we require total accuracy, must be done as part of each calculation. When there are thousands of such conversions/calculations to be done this mounts up.
As long as we are dealing with very small rounding errors we need not worry because they will never build up to such an extent as to have any noticeable effect on what we are trying to calculate.
For example, calculating an on-screen pixel position to 2 places of decimals would achieve little.
Floats are designed to calculate numerical results over a huge range, whilst not requiring the additional time-consuming overhead of base numbering scheme conversion.
Therefore, you should never use Floats in any situation where absolute comparisons/values may be required.
They do save time of course, when compared to decimal. It’s a case of “horses for courses”.
Terry
PS Having just read Wolfgang's reply I'm just guessing that SetFloatDelta() gives an accuracy limitation on Floats, allowing the compiler to do things to whatever accuracy is required.
So rather than saying never use Floats, I guess it should be "do not use floats unless SetFloatData() is set.
That is just a guess.
- softdevo@tiscali.it
- Posts: 191
- Joined: Wed Sep 30, 2015 1:30 pm
If someone can explain it to me?
Thanks to all, but I don't understand why with any other value it gives a correct result and only 8.70 gives error, then multiplying by 100 should not generate any rounding.
Another thing I don't understand is why the same code in any other application works.
I will try your suggestions, but I'm not satisfied, because every calculation is therefore in danger.
Danilo
Another thing I don't understand is why the same code in any other application works.
I will try your suggestions, but I'm not satisfied, because every calculation is therefore in danger.
Danilo
If someone can explain it to me?
Hi Danilo,
Some decimal numbers can be represented better than others. For example, the decimal value 0.625 can be perfectly represented in binary accurately as 0.101, while 0.626 can only be represented in approximation.
The important question is, do you get a problem in your app while running it, or is it just the value you see in the debugger that you do not like? Because normally, when you actually print values to show to the user, you use some kind of rounding, which will eliminate that precision lost.
Some decimal numbers can be represented better than others. For example, the decimal value 0.625 can be perfectly represented in binary accurately as 0.101, while 0.626 can only be represented in approximation.
The important question is, do you get a problem in your app while running it, or is it just the value you see in the debugger that you do not like? Because normally, when you actually print values to show to the user, you use some kind of rounding, which will eliminate that precision lost.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
If someone can explain it to me?
Hi Danilo
Unfortunately, as Karl said, I could not read your post properly.
I made an assumption that it was probably due to rounding errors. I should not have done this - there may be other factors at play here.
We need to see the full code properly.
Sorry if I've managed to steer this discussion in the wrong direction.
Terry
Unfortunately, as Karl said, I could not read your post properly.
I made an assumption that it was probably due to rounding errors. I should not have done this - there may be other factors at play here.
We need to see the full code properly.
Sorry if I've managed to steer this discussion in the wrong direction.
Terry
If someone can explain it to me?
No worries Terry, I think both your and Karl's points were valid as well.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
If someone can explain it to me?
Thanks Chris. It will be interesting to see what the problem turns out to be.
Terry
Terry