IonicWind Software

IWBasic => General Questions => Topic started by: obelisk on March 16, 2015, 07:44:08 PM

Title: Help converting from C++
Post by: obelisk on March 16, 2015, 07:44:08 PM

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.
Title: Re: Help converting from C++
Post by: LarryMc on March 16, 2015, 08:57:03 PM
I don't know C++ either but would assume that it follows the standard order of mathematical precedence.
Title: Re: Help converting from C++
Post by: GWS on March 17, 2015, 04:53:09 AM
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
Title: Re: Help converting from C++
Post by: obelisk on March 20, 2015, 05:50:49 PM
Thank you for your help!