Caveat Emptor: Negative Calculations with Fractions

This forum is for general discussion regarding VCarve Pro
Post Reply
CNCDaveToo
Posts: 26
Joined: Mon Jan 22, 2018 3:47 am
Model of CNC Machine: ShopBot D2418
Location: Leesburg, Virginia, USA

Caveat Emptor: Negative Calculations with Fractions

Post by CNCDaveToo »

I've always appreciated how you could enter something like "1 2/3=" into a calculation field and have it automagically replace it with "1.66667". I'm constantly using this feature and praising the VCP team for it :)

There is a dark side to this feature that I hit recently. I entered "-1 2/3=" and since I'm so accustomed to using this functionality, I didn't bother checking the result. When things went sideways, it took a few minutes to find the culprit. Entering "-1 2/3=" results in "-0.33333" (and not the "-1.66667" that I had ass-u-me-d it would be).

I thought I'd found a bug, and reported it. Support replied that:
This is not really a bug, I am afraid that it is just how the math works with the notation.

To enter in 1 and 2/3 as a negative, you would need to enter in (1 2/3)*-1=
So it appears that in a calculation, a space is interpreted as a plus sign. Hence "-1 2/3=" is read as "negative one plus two thirds".

I get it, it makes the parsing dirt simple. It just caught me off guard and left me scratching my head wondering if that's hit me elsewhere that I haven't noticed (yet).

I just wanted to point this out to help others avoid the head scratching it took me to find. :)
Be kind.

User avatar
mezalick
Vectric Wizard
Posts: 2980
Joined: Mon Nov 03, 2008 9:07 am
Model of CNC Machine: Camaster Cobra
Location: Philadelphia, PA USA
Contact:

Re: Caveat Emptor: Negative Calculations with Fractions

Post by mezalick »

Good to know,
Thanks

Michael
Michael Mezalick
https://www.youtube.com/user/mezalick
mm@mezalick.com

User avatar
Leo
Vectric Wizard
Posts: 4086
Joined: Sat Jul 14, 2007 3:02 am
Model of CNC Machine: 1300 x 1300 x 254 Chinese Made
Location: East Freetown, Ma.
Contact:

Re: Caveat Emptor: Negative Calculations with Fractions

Post by Leo »

Makes perfect algebraic sense, but to anyone that is a bit math challenged it is easy to imagine how that would seem a bit sideways.

Good on you for posting that.
Imagine the Possibilities of a Creative mind, combined with the functionality of CNC

User avatar
Rcnewcomb
Vectric Archimage
Posts: 5908
Joined: Fri Nov 04, 2005 5:54 am
Model of CNC Machine: 24x36 GCnC/WinCNC with ATC
Location: San Jose, California, USA
Contact:

Re: Caveat Emptor: Negative Calculations with Fractions

Post by Rcnewcomb »

Honestly, I was surprised that they allow the space. I've always been entering

Code: Select all

1+5/8=
- Randall Newcomb
10 fingers in, 10 fingers out, another good day in the shop

User avatar
adze_cnc
Vectric Wizard
Posts: 4364
Joined: Sat Jul 27, 2013 10:08 pm
Model of CNC Machine: AXYZ 4008
Location: Vancouver, BC, Canada

Re: Caveat Emptor: Negative Calculations with Fractions

Post by adze_cnc »

Try: -1*(1 2/3) in the future.

CNCDaveToo
Posts: 26
Joined: Mon Jan 22, 2018 3:47 am
Model of CNC Machine: ShopBot D2418
Location: Leesburg, Virginia, USA

Re: Caveat Emptor: Negative Calculations with Fractions

Post by CNCDaveToo »

Rcnewcomb wrote:
Thu Mar 19, 2020 4:04 pm
Honestly, I was surprised that they allow the space. I've always been entering

Code: Select all

1+5/8=
Of course. The even simpler solution becomes:

Code: Select all

-1-2/3
((I was getting hung up on the whole "multiply by negative one" aspect of it -- this is simpler))

-- Thanks RC
Be kind.

Post Reply