double math error in macro

If you think you've found a bug post it here.

Re: double math error in macro

Postby ger21 » Mon Aug 28, 2017 6:02 pm

No, the exponent is coming from your math operation, and is a C# issue, not a UCCNC issue.
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2663
Joined: Sat Sep 03, 2016 2:17 am

Re: double math error in macro

Postby merrick » Mon Aug 28, 2017 6:36 pm

ger21 wrote:No, the exponent is coming from your math operation, and is a C# issue, not a UCCNC issue.


It is not strictly my math operation. These math operations are routine in macros, including yours. I just happen to have a corner case that jumps out.

C# has a way to convert double to string without using exponent format, but as far as I know, it is not available in the UCCNC C# macro environment. Blaming it on C# is not a solution because UCCNC has control of the C# macro environment.

I reported what I observed in hope of improving the software and benefiting all users. Now that I understood the root of the issue, I'll hopefully find a work around solution.
merrick
 
Posts: 32
Joined: Fri Aug 18, 2017 8:20 pm

Re: double math error in macro

Postby dezsoe » Mon Aug 28, 2017 6:39 pm

OK, the issue is double math, C# and UCCNC issue together. A double is handled as is, you cannot change it. C# automatically converts your double to string when adding to a string: I personally hate automatic conversion, I always convert as I need. This time you should use .ToString("F6") to make the conversion and rounding together. UCCNC's issue is that it cannot handle exp. numbers as parameters. You can work-around it: put your result in a # variable (there the exp. expression is allowed) and G0 Y#1.

In short: IMHO the best way is to convert explicitly with .ToString("F6") or as many decimals as you need.
dezsoe
 
Posts: 2049
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: double math error in macro

Postby merrick » Mon Aug 28, 2017 7:07 pm

Thanks, dezsoe. I think that's exactly what'll do for now.
merrick
 
Posts: 32
Joined: Fri Aug 18, 2017 8:20 pm

Re: double math error in macro

Postby cncdrive » Mon Aug 28, 2017 8:18 pm

merrick wrote:
ger21 wrote:No, the exponent is coming from your math operation, and is a C# issue, not a UCCNC issue.


It is not strictly my math operation. These math operations are routine in macros, including yours. I just happen to have a corner case that jumps out.

C# has a way to convert double to string without using exponent format, but as far as I know, it is not available in the UCCNC C# macro environment. Blaming it on C# is not a solution because UCCNC has control of the C# macro environment.

I reported what I observed in hope of improving the software and benefiting all users. Now that I understood the root of the issue, I'll hopefully find a work around solution.


Well, you doing the Math in your macro which causing the issue. The UCCNC has no control over C# libraries, like the Math library. The UCCNC also has no control over what string you sending as parameter to the exec.Code function.
We can't resolve issues you create with using C# math functions, it is something you have to take care of and handle the issue with converting the number to make sure to remove the exponent notation when sending it to the executer as a G-code coordinate string, because exp. notations are not allowed in g-codes.
cncdrive
Site Admin
 
Posts: 4695
Joined: Tue Aug 12, 2014 11:17 pm

Re: double math error in macro

Postby merrick » Mon Aug 28, 2017 10:20 pm

Do what you want with the report. I'll not waste any more time on bugs
merrick
 
Posts: 32
Joined: Fri Aug 18, 2017 8:20 pm

Re: double math error in macro

Postby cncdrive » Mon Aug 28, 2017 10:25 pm

What bugs are you talking about? You did not reported any yet, because this is not a bug, but how Math works on computers.
And you can easily find a solution for loss-less conversion of numbers to strings without the exp. notation mark: https://stackoverflow.com/questions/154 ... c-notation
First answer in the post.
cncdrive
Site Admin
 
Posts: 4695
Joined: Tue Aug 12, 2014 11:17 pm

Previous

Return to Report a bug

Who is online

Users browsing this forum: No registered users and 5 guests