Jump to content

Math Help


Recommended Posts

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

Link to comment
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
Link to comment
Share on other sites

  • Moderators

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.

So your line should read:

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

and then you get the "correct" answer!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

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

Link to comment
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.

^_^

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Link to comment
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..

Link to comment
Share on other sites

its Gr3 math in canada

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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...