Complex equations??
James Long
Posts: 1,181
Ok....what is the proper way to input complex equations into the IDE?
Like the following · √return_value * 2 / 1.225
would it be : showvalue := ^^((return_value * 2)/1.225)
I also know this would require the Float to string object. Because the result it a floating point number.
James L
·
Like the following · √return_value * 2 / 1.225
would it be : showvalue := ^^((return_value * 2)/1.225)
I also know this would require the Float to string object. Because the result it a floating point number.
James L
·
Comments
Wouldn't I actually have to do·3 steps.....FMul...... FDiv....then FSqr?
Because I'm doing three different floating point calculations.
James
I'll have to work· up the equation and see how it comes out.
James
I'm displaying by the hyperterminal....maybe it's my method of displaying them.
Seems to dsiplay the right number....I really need to check.....but it doesn't have a decimal point.....is this usual?
Man there are so many things that I'm trying to do....that I've never done...
James L
To be honest...I'm outputing the value with a dec command. I'm not outputing with a string.
I'm concerned the program is loosing the decimal point location. If I convert to a string will the decimal point be in the right place?
Hmmm.....more learning.
James
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 9/25/2006 10:41:51 PM GMT
I'm already using the PC_debug item that uses the fullduplex.
That will help......I'll post my results.
James
That didn't work....the floattostring says it needs a urinary......hmmm
Oh well,
James
Try serial.str(floatString.FloatToString(flt.FSqr(flt.FDiv(flt.FMul(return_value,2.0),1.225)))) where serial is the FullDuplexSerial driver, floatString is the FloatString object and flt is the FloatMath object. This should transmit an ASCII string with the value of the result of sqrt(return_value*2.0/1.225)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Here it is......didn't know I could put it all into one....
····· ShowValue1 := f.fmul(Return_Value , 1.22)
····· ShowValue1 := f.fdiv(ShowValue1 , 450)
····· ShowValue1 := f.fmul(1000.000 , ShowValue1)
····· ShowValue1 := f.fmul( ShowValue1 , 2.000)
····· ShowValue1 := f.fdiv( ShowValue1 , 1.225)
····· ShowValue1 := f2.floattostring(^^ShowValue1)
····· debug.str(string(ShowValue1))
Do I have to convert the "Return_Value" to a float before I do all of this?
This is a mixed up mess.....so bear with my messy code. I've tried a few things (that didn't work). f = float32· f2 = floattostring
James
I have another equation....I'm not sure how to put it:
Z = --26216 x ln( P(kPa) / 101.304 )
What has me is the "--26216".....can't figure out how to place that in an equation.
James
You'd have FMul(constant(-26216.0),FDiv(...,101.304)) where the ... is the P(kPa).
I've done some research...and I think the "--" symbol means a negative exponent, but I'm not too sure.
Someone check me on my input of this to make sure i'm not doing something wrong.
I'm getting raw values.....but only 0.0 for the computated values.
Hmmmmm.....Still getting close.....just need someone to check my syntax....and make sure I'm not missing something....which I would have to be.
James
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Yea.....I'm still confused about the equation. I took that part of it out...and actually got a neg number.
I really don't have a clue at this point.....but I'll find out.
I'll do more research......Blahhh.......
James
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
To be frank (whoever that is) it's been a long time since I did any equations that complex. I don't remember much, because I didn't do many like that way back when.
I'm having to ask a friend that has done these equations for a project a few years ago.
James
NOTE:I have not confirmed that this is accurate.....just that I get numbers out.
Trust me when I say.....it took a a few tries to get it right.
James