Weird calculation

Weird calculation

briannystadvej
Advocate Advocate
2,015 Views
17 Replies
Message 1 of 18

Weird calculation

briannystadvej
Advocate
Advocate

Hi

 

Can anyone explain to me why powermill comes up with such result.. Look at UpperLimitvariable. It should only be 3,6 , but comes out with long trails of zeros.. Why ???

 

 

weird.JPG

0 Likes
Accepted solutions (1)
2,016 Views
17 Replies
Replies (17)
Message 2 of 18

GlennM.MCAM
Collaborator
Collaborator

I don't know why it does this, but to prevent it from doing this I use the "round" function.

 

 

REAL UpperLimit = $Depth - ($Depth / $Step)
$UpperLimit = ROUND ($UpperLimit, 4)

 

Glenn

 


Intel i7 4790 @ 3.60GHz -16GB RAM - Nvidia Quadro K620 - 250GB SSD - Win 7 Pro x64 SP1
PowerMILL Premium 2019.1 - PowerINSPECT Ultimate OMV 2017 SP6
Message 3 of 18

briannystadvej
Advocate
Advocate

Hi @GlennM.MCAM

 

Thanks.. I know about rounding up, but it doesn't explain the behavior of the calculation.

0 Likes
Message 4 of 18

Anonymous
Not applicable

Hi,

The problem is with computers architecture. Precision of calculations is depend on posibility to write a floating point number on bytes. There is a few posibilitys to correct this calculation error, but neither is perfect. That's why this sytuation is happend. Rounded function should be implemented in code of program, and automaticly correct the results. So this is a job for Autodesk programmers.

 

 

Mateusz

Message 5 of 18

briannystadvej
Advocate
Advocate

Thanks for the answer..

 

Think it's weird that a small 1$ dollar calculator can get correct result, but a 2000$ pc can't Smiley LOL

0 Likes
Message 6 of 18

Anonymous
Not applicable

So why if you use binoculars for few $ you can't see the craters of the moon, but if you use a telescope for few thousand $ you can?

 

I mean the result is corect in both cases, but in second the result is more accurate.

 

 

Mateusz

0 Likes
Message 7 of 18

urizenYHS3W
Advocate
Advocate

Which would you prefer

3,6000000000000005

or

3,60

followed by debugging why you get this result

 

  IF UpperLimit <= 3.60 {

    // doesn't enter this block

  } ELSE {

    // UpperLimit is greater than 3.6

  }


0 Likes
Message 8 of 18

GlennM.MCAM
Collaborator
Collaborator

Why even bother? I'm pretty sure 0.0000000000000005 mm is not a value a milling machine can handle Smiley Very Happy

Round it up and never think about it again Smiley Wink


Intel i7 4790 @ 3.60GHz -16GB RAM - Nvidia Quadro K620 - 250GB SSD - Win 7 Pro x64 SP1
PowerMILL Premium 2019.1 - PowerINSPECT Ultimate OMV 2017 SP6
0 Likes
Message 9 of 18

urizenYHS3W
Advocate
Advocate

Perhaps but numeric rounding errors quickly mount up.

 

0 Likes
Message 10 of 18

briannystadvej
Advocate
Advocate

It's not the point. It was why it comes up with such result.

 

In principle it's a wrong result no matter how many decimals there is. Smiley Wink  or I am I not correct in that ?

 

0 Likes
Message 11 of 18

GlennM.MCAM
Collaborator
Collaborator

Theoretically you are right, but isn't our job to put the theory into practice? I'm very happy with a rounded 0.001mm value, which means the maximum deviation is 0.0005mm.

 

@urizenYHS3W I wouldn't calculate rounded numbers with each other, only round up the end result.


Intel i7 4790 @ 3.60GHz -16GB RAM - Nvidia Quadro K620 - 250GB SSD - Win 7 Pro x64 SP1
PowerMILL Premium 2019.1 - PowerINSPECT Ultimate OMV 2017 SP6
0 Likes
Message 12 of 18

briannystadvej
Advocate
Advocate

I'm also satisfied with the rounded result.

 

@Anonymous explained me why it is like that.

0 Likes
Message 13 of 18

urizenYHS3W
Advocate
Advocate

From what I recall the form should show the value rounded to 6dp. But here you are looking in the debugger window which is displaying the parameter's true value.

 

0 Likes
Message 14 of 18

NanchenO
Collaborator
Collaborator

Don't forget that handling CAD files is ALWAYS using tolerances.

 

Did you never notice that some dimensions are not rounded, but that they are some small decimals ? Already when you import a model (of +/- good quality), it is handled/converted with a certain precision, given in your default parameters

 

-> It is absolutely normal that some values are no longer 100% rounded after some calculations or geometrical manipulations.

 

-> A good CAM software does not need to be mathematically 100% accurate, it just needs to do the job at least as well as your machine can handle it ! The final unaccuracy is the sum of a bad geometry, a too large calculation tolerance and an old machine working at 30°C !

 

Olivier

0 Likes
Message 15 of 18

briannystadvej
Advocate
Advocate

 

What I was asking wasn't about geometrical tolerances or accuracy. It was about why it made such "calculation mistake" 

 

That mistake isn't about CAD/CAM tolerances, but about what piro_man explained. 

0 Likes
Message 16 of 18

Anonymous
Not applicable

@urizenYHS3W wrote:

Which would you prefer

3,6000000000000005

or

3,60

It's not the case what I, you, or anybody else prefer. It's about bit operations and accuracy of calculation. Computer is not a human, it doesn't think, just doing what you want. It "doesn't know" what it calculates and with what accuracy, that's why it should do this as much accuracy as it can.


Take a look of this sytuation: what if you would calculate, for example, the number Pi with an accuracy to the n-th place after the comma? Then you will be angry if the resoult would be rounded. Or if you will calculate somthing partly, then every step of rounded calculation will be couse of bigger calculation error. Belive me, people are calculating things, with accuracy that we did't even know. If it would be locked and rounded by hardware, it would be impossible to get the correct result.


So I repeat, this is the job for Autodesk programmers to adapt software to our needs. It's not the computers fault because it represents the results as much accuracy as it can.

 

 

Mateusz

 

Message 17 of 18

GlennM.MCAM
Collaborator
Collaborator

brucealmighty-comedy-and-thats-the-way-the-cookie-crumbles-grab-26816114.png


Intel i7 4790 @ 3.60GHz -16GB RAM - Nvidia Quadro K620 - 250GB SSD - Win 7 Pro x64 SP1
PowerMILL Premium 2019.1 - PowerINSPECT Ultimate OMV 2017 SP6
Message 18 of 18

urizenYHS3W
Advocate
Advocate
Accepted solution

@Anonymous wrote:

So I repeat, this is the job for Autodesk programmers to adapt software to our needs. It's not the computers fault because it represents the results as much accuracy as it can.

 



The calculations are always done to the full precision and the values are never rounded. Most comparisons are done at 1e-10 so X == Y will be true as long as the values of X and Y do not differ by a ten billionth. Some comparisons such as zheights are done to a coarser value of 1e-5.

 

The values may be rounded in the GUI display so that you see 1.0 rather than 1.xxx-xxxxxxxx but the internal value will remain 1.xxx-xxxxxxxx. The debug window however is different as it does not show the rounded values but their true values. This allows someone that is debugging macro code to see the real value.