May 18, 2024, 01:40:54 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Help converting from C++

Started by obelisk, March 16, 2015, 07:44:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

obelisk


I am trying to covert some code that was written in C++

dd=( ir + t - 3.1415927 / 4.0 * ( ir + kn1 * t ) ) * kn* 2

If I write the same formula in IWbasic, will the result be the same? Or do I need extra parenthesis to separate things?

Basically, I am not sure if IWBasic treats (+ - * /) the same way C++ does. I do not program in C++, so I am not sure.

Thanks in advance for your help.

LarryMc

I don't know C++ either but would assume that it follows the standard order of mathematical precedence.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

GWS

Hi Obelisk.

The order of preference in C++ is the same as in IWB - ie: () * / + -

However, that is one awkward equation.  If you consider it split into a few auxiliary parts -

a1 = ir + t
a2 = 4.0 * (ir + kn1 * t)
a3 = kn * 2

dd = (a1 - 3.1415927 / a2) * a3

Without knowing what physical application the equation relates to, I couldn't be sure if that evaluation is correct. ::)

Best wishes, :)

Graham
Tomorrow may be too late ..

obelisk