[solved] math power operator **

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
Charles Dyer
Junior Member
Posts: 16
Joined: Wed Nov 28, 2018 9:17 pm

[solved] math power operator **

Post by Charles Dyer » Sun Jan 10, 2021 4:45 am

Version: Pro 3.25.2.0 (3.25.2) on Ubuntu 16.04

As the scripting language is said to be ECMA script which seems to have a power operator '**' I am puzzled because this seems to raise an error when I try to use it. It appears that I can use Math.pow(x,y) but this is not very convenient to use in many mathematical expressions.

Is it the case that the QCAD scripting language does not support the "**" operator, or is there something that I am missing here?

Thanks, and cheers,

- charles

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: math power operator **

Post by CVH » Sun Jan 10, 2021 6:16 am

The exponentiation '**' is ECMAScript 6 also known as ES6 and ECMAScript 2015.
What was the second major revision to JavaScript.

There is no solution, you cannot polyfill operators. :oops:

Regards,
CVH

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: math power operator **

Post by andrew » Sun Jan 10, 2021 12:11 pm

You can use Math.pow() or in QCAD also simply pow().

Charles Dyer
Junior Member
Posts: 16
Joined: Wed Nov 28, 2018 9:17 pm

Re: math power operator **

Post by Charles Dyer » Sun Jan 10, 2021 10:07 pm

Thanks for the help.
- charles

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: [solved] math power operator **

Post by CVH » Mon Jan 11, 2021 6:45 am

I am a little puzzled by Andrew's answer.
At first it seemed that one wants to criticize my help, again, but now it seems even more incorrect to me.

The topic is clearly about scripting.
Charles Dyer wrote:
Sun Jan 10, 2021 4:45 am
scripting ... many mathematical expressions.
Charles Dyer wrote:
Sun Jan 10, 2021 4:45 am
Is it the case that the QCAD scripting language does not support the "**" operator?
CVH wrote:
Sun Jan 10, 2021 6:16 am
'**' is ES6.
The ECMAScript language implementation is basic, prior to ES6.
A direct question for the language version was never answered.
https://qcad.org/rsforum/viewtopic.php?t=6945&p=26672

It supports RMath.pow(base, exponent).
It doesn't support the exponentiation operator '**', and one can not polyfill an operator.


Charles Dyer wrote:
Sun Jan 10, 2021 4:45 am
Math.pow(x,y) ... is not very convenient
andrew wrote:
Sun Jan 10, 2021 12:11 pm
You can use Math.pow() or in QCAD also simply pow().
The simple.js script implements the derivative pow(base, exponent) for the use in the QCAD GUI.
But it should be avoided in scripting.
https://qcad.org/rsforum/viewtopic.php? ... 539#p24541
andrew wrote:
Wed Aug 28, 2019 8:40 pm
These should be avoided in scripts and are meant for user level input fields.


Having clarified that,
I am considering to revoke all notifications.
CVH

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: [solved] math power operator **

Post by andrew » Mon Jan 11, 2021 10:36 am

CVH wrote:
Mon Jan 11, 2021 6:45 am
At first it seemed that one wants to criticize my help, again, but now it seems even more incorrect to me.
Not at all, my reply was just meant as an addition to your reply. I will contact you in PM about your other statements.

Post Reply

Return to “QCAD 'How Do I' Questions”