# Math Help

## Recommended Posts

\$x = 1.87 * 1.5 * 73 + 9.40 * 1.5 * 24 + 4.03 * 3 / 100

This should equal 5.55255 BUT it returns 543.2859

Need a website: http://www.iconixmarketing.com

##### Share on other sites

OK it doent like the string. Works like this:

```\$x = 1.87 * 1.5 * 73
\$x2 = 9.40 * 1.5 * 24
\$x3 = 4.03 * 3
\$x4 = \$x + \$x2 + \$x3
\$x5 = \$x4 / 100

MsgBox(-1, \$x5, \$x5)```

Is there a way to write this on 1 line?

Need a website: http://www.iconixmarketing.com

##### Share on other sites

OK it doent like the string. Works like this:

```\$x = 1.87 * 1.5 * 73
\$x2 = 9.40 * 1.5 * 24
\$x3 = 4.03 * 3
\$x4 = \$x + \$x2 + \$x3
\$x5 = \$x4 / 100

MsgBox(-1, \$x5, \$x5)```

Is there a way to write this on 1 line?

\$x = (1.87 * 1.5 * 73 + 9.40 * 1.5 * 24 + 4.03 * 3) / 100

##### Share on other sites

\$x = (1.87 * 1.5 * 73 + 9.40 * 1.5 * 24 + 4.03 * 3) / 100

you've beaten me on time

@OP

\$x = 1.87 * 1.5 * 73 + 9.40 * 1.5 * 24 + 4.03 * 3 / 100 = 543.2859

##### Share on other sites

onestcoder,

Your maths syntax is very anbiguous. You should always clearly show, by the use of parentheses, the order in which the operators are to be applied - if not the compiler uses its own priority listing. From the Help File:

```When more than one operator is used in an expression the order in which things happen is controlled by operator precedence.  The precedence used in AutoIt is given below.  Where two operators have the same precedence the expression is evaluated left to right.

From highest precedence to lowest:

NOT
^
* /
+ -
&
< > <= >= = <> ==
AND OR

e.g. 2 + 4 * 10 is evaluated as 42:

4 * 10  (equals 40)

2 + 40  (equals 42)

As the * has a higher precedence than + it occurs before the addition.```

`\$x = ((1.87 * 1.5 * 73) + (9.40 * 1.5 * 24) + (4.03 * 3)) / 100`

and then you get the "correct" answer!

M23

AnyÂ of myÂ own codeÂ posted anywhere on the forumÂ isÂ available for use by others without any restrictionÂ of any kind._______My UDFs:

Spoiler

ArrayMultiColSortÂ ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- AÂ highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort,Â edit and colourÂ ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Â

##### Share on other sites

but what about bedmas? it shouldn't need the brackets... should it

##### Share on other sites

\$x = ((1.87 * 1.5 * 73) + (9.40 * 1.5 * 24) + (4.03 * 3)) / 100

((1.87 * 1.5 * 73) + (9.40 * 1.5 * 24) + (4.03 * 3)) / 100 = (1.87 * 1.5 * 73 + 9.40 * 1.5 * 24 + 4.03 * 3) / 100

Multiplication (division) ALWAYS has preoritet over addition (subtraction). This is mathematics (Grade ~3). There's no need to read the help file.

##### Share on other sites

Yashied,

My mathematics teachers of long, long ago taught me to use parentheses to avoid any possible confusion.

The OP was confused - using parentheses removes the confusion.

I just used more of them than you did!

CodyBarrett,

I have never come across "bedmas" before - I will try to remember it.

M23

AnyÂ of myÂ own codeÂ posted anywhere on the forumÂ isÂ available for use by others without any restrictionÂ of any kind._______My UDFs:

Spoiler

ArrayMultiColSortÂ ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- AÂ highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort,Â edit and colourÂ ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

Â

##### Share on other sites

The OP was confused - using parentheses removes the confusion.

I just used more of them than you did!

I understand it, just OP so better remember.

##### Share on other sites

Thank you very much (Yashied, Melba23, CodyBarrett, oMBRa)

Need a website: http://www.iconixmarketing.com

##### Share on other sites

Yashied,

My mathematics teachers of long, long ago taught me to use parentheses to avoid any possible confusion.

The OP was confused - using parentheses removes the confusion.

I just used more of them than you did!

CodyBarrett,

I have never come across "bedmas" before - I will try to remember it.

M23

I've never heard of bedmas, what's the B? Brackets?

I've always been taught PEMDAS. Parenthesis, etc..

##### Share on other sites

B rackets

E xponents

D ivision

M ultiplication

A dding

S ubtracting

... not sure if it applies to programming though.. but up there it does

## Create an account

Register a new account

×

• Wiki

• Back

• Git