Power operator "^" does not work, but rather acts as addition. For instance 3^3 should equal 27 (3 raised to the 3rd power) but instead results in 6 (3+3).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Snehal Brahmbhatt’s picture

Try the patch webform_calculator-fixes_for_power_operator-2502619-1-D7.patch to resolve the issue you are facing.

Apply patch in webform_calculator/webform_calculator.js file.

Let me know incase of any concern/query regarding this.

Thanks,
Snehal Brahmbhatt | AddWeb Solution
https://www.drupal.org/user/3147795/track

Snehal Brahmbhatt’s picture

Snehal Brahmbhatt’s picture

Status: Active » Needs review
Snehal Brahmbhatt’s picture

FileSize
1.26 KB

Try the patch power_operator_does-2502619-4.patch to resolve the issue you are facing.

Apply patch in webform_calculator/webform_calculator.js file.

Let me know incase of any concern/query regarding this.

Thanks,
Snehal Brahmbhatt | AddWeb Solution
https://www.drupal.org/user/3147795/track

Snehal Brahmbhatt’s picture

Version: 7.x-2.0-alpha2 » 7.x-1.x-dev
Snehal Brahmbhatt’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev

Please test the patches provided in #2 & #4 for Version 7.x-2.x-dev

saurabh.dhariwal’s picture

Status: Needs review » Reviewed & tested by the community
rafenden’s picture

Priority: Critical » Major
Status: Reviewed & tested by the community » Needs work

Thanks for patch snehal.brahmbhatt.
I've tested it didn't work for me when using with formula {a} ^ 2.
Additionally we should provide a patch for PHP code.

rafenden’s picture

Title: Power operator "^" does not work, acts as addition » Support for power operator (^)
Category: Bug report » Feature request

Since power operator was removed changing category to feature request.

Snehal Brahmbhatt’s picture

Hi Rafal,

PFA patch for PHP code per your request. Check once and let me know your thoughts.

Snehal Brahmbhatt’s picture

Status: Needs work » Needs review
Snehal Brahmbhatt’s picture

FileSize
2.34 KB

Ignore #10 and check the latest updated Patch: "support_for_power-2502619-12.patch". This contains combined code for Javascript and PHP.

MichaelWimpey’s picture

Hi Snehal Brahmbhatt, Thanks for the work on this so far, this is definitely a useful feature, which seems to be working, but on form submission, is giving the following error:

Error message
Warning: Division by zero in eval() (line 1 of .../sites/all/modules/webform_calculator/webform_calculator.module(55) : eval()'d code).

colemanw’s picture

Reading the patch in #12 it looks like this will limit expressions to either use a power or other operators. So currently {a} + {b} / {c} works, but {a} + {b}^{c} will not.

lcfi’s picture

Computed values with arent saved in the database. We are looking for a paid solution to that problem.

Lawrence

  • colemanw committed 298ab27 on 7.x-2.x
    Issue #2502619 - Support more math operators
    
    Adds 3rd party math...
colemanw’s picture

Status: Needs review » Fixed

Fixed by incorporating 3rd-party math libraries. This module now supports a slew of math operators and functions, not just ^.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.