Opened 11 years ago

Closed 9 years ago

Last modified 9 years ago

#2364 closed defect (fixed)

Math order of operations changes after file save

Reported by: anonymous Owned by: Adeel Asghar
Priority: critical Milestone: 1.9.4
Component: OMEdit Version: trunk
Keywords: Cc:

Description

When writing an equation in OMEdit and using parenthesis to dictate the desired order of operations, the equation is changed after file save. When the following formula is evaluated in OMShell just as it is typed here:

hl:=f*(pipelength/(pipediameter/12))*((vin2)/(2*g))

37.77689569419355

The correct answer is given. When the same formula is saved in OMShell, some of the parenthesis are removed which changes the order of evaluation. The result after the file save is:

hl = f * pipelength / pipediameter / 12 * vin 2 / (2 * g)

Which, when copied to OMShell and evaluated gives the following:

hl := f * pipelength / pipediameter / 12 * vin 2 / (2 * g)
0.26233955343189963

Which is clearly the wrong answer.

Change History (10)

in reply to:  description comment:1 by anonymous, 11 years ago

Replying to anonymous:

When writing an equation in OMEdit and using parenthesis to dictate the desired order of operations, the equation is changed after file save. When the following formula is evaluated in OMShell just as it is typed here:

hl:=f*(pipelength/(pipediameter/12))*((vin2)/(2*g))

37.77689569419355

The correct answer is given. When the same formula is saved in OMShell, some of the parenthesis are removed which changes the order of evaluation. The result after the file save is:

hl = f * pipelength / pipediameter / 12 * vin 2 / (2 * g)

Which, when copied to OMShell and evaluated gives the following:

hl := f * pipelength / pipediameter / 12 * vin 2 / (2 * g)
0.26233955343189963

Which is clearly the wrong answer.

The above formulas looked correct when I pasted them into the comments window, but the formatting looks different when viewing the submitted ticket. it appears that saving the model file is changing the intended formula from (vin2)/(2*g) to vin(2/(2*g))

comment:2 by Adrian Pop, 11 years ago

You can surround the text with 3 accolade parentheses on both sides to keep it exactly as it is, no wiki formatting, i.e. exactly as you type formatted text .

comment:3 by Martin Sjölund, 11 years ago

Milestone: 1.9.01.9.1

Postponed until 1.9.1

comment:4 by Martin Sjölund, 10 years ago

Milestone: 1.9.11.9.2

This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).

comment:5 by Martin Sjölund, 10 years ago

Milestone: 1.9.21.9.3

Milestone changed to 1.9.3 since 1.9.2 was released.

comment:6 by Martin Sjölund, 9 years ago

Milestone: 1.9.31.9.4

Moved to new milestone 1.9.4

comment:7 by Adeel Asghar, 9 years ago

Status: newaccepted

This issue has now been fixed in a development branch https://github.com/adeas31/OMEdit/tree/indentation for OpenModelica 1.9.4 final release.

comment:8 by Adeel Asghar, 9 years ago

Resolution: fixed
Status: acceptedclosed

The fix is now available via the nightly build.

comment:9 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.4-1.9.x

Milestone renamed

comment:10 by Martin Sjölund, 9 years ago

Milestone: 1.9.4-1.9.x1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.