Board index » cppbuilder » Re: What's wrong with this

Re: What's wrong with this


2003-09-05 02:30:25 AM
cppbuilder38
"Aaron" < XXXX@XXXXX.COM >writes:
Quote
void __fastcall TForm6::Button1Click(TObject *Sender)
{
r = StrToFloat(Edit1 ->Text);
f = StrToFloat(Edit2 ->Text);
e = StrToFloat(Edit3 ->Text);
if (e>=0)
{s = 3.86*sqrt(r*(f+e));}
else
{s = 3.86*sqrt(r*(f-e));}
Edit4 ->Text = FormatFloat("0.0000",s);
}

It will add e but it won't subtract.
Any help appreciated,
Please give examples of what the data is in the Edit1..3, what your
expected result is, what the values of r, f, e are, and what actually
resulted.
--
Chris (TeamB);
 
 

Re:Re: What's wrong with this

OK, sorry..
this is an equation.... I am trying to find the value of s, therefore, s
should equal 3.86 times the square root of r times the sum of f + or - e.
The values are provided by the user.
Example, when I input r = 250 and f = .70 and e = .03 I get 52.11. When I
input e as a negative number it still adds instead of subtracts and I still
get 52.11. Everything works fine except it won't subtract the value of e if
user inputs a negative number.
Equation looks something like s = 3.86*sqrt r(f +- e)
Thanks again,
Aaron
PS - This is an equation that accident reconstructionists use to find the
critical speed of a yaw.
"Chris Uzdavinis (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote
"Aaron" < XXXX@XXXXX.COM >writes:

>void __fastcall TForm6::Button1Click(TObject *Sender)
>{
>r = StrToFloat(Edit1 ->Text);
>f = StrToFloat(Edit2 ->Text);
>e = StrToFloat(Edit3 ->Text);
>if (e>=0)
>{s = 3.86*sqrt(r*(f+e));}
>else
>{s = 3.86*sqrt(r*(f-e));}
>Edit4 ->Text = FormatFloat("0.0000",s);
>}
>
>It will add e but it won't subtract.
>Any help appreciated,

Please give examples of what the data is in the Edit1..3, what your
expected result is, what the values of r, f, e are, and what actually
resulted.

--
Chris (TeamB);
 

Re:Re: What's wrong with this

"Aaron" < XXXX@XXXXX.COM >wrote in message
Quote
PS - This is an equation that accident reconstructionists
use to find the critical speed of a yaw.
What kind of project are you making overall? I know an AR. Depending on
what you're making, I might suggest it to him for review.
Gambit
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 9/1/03
 

{smallsort}

Re:Re: What's wrong with this

Chris, I feel so silly. Thanks for bumping my brain back on track :)
Aaron
"Chris Uzdavinis (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote
"Aaron" < XXXX@XXXXX.COM >writes:

>OK, sorry..
>this is an equation.... I am trying to find the value of s, therefore, s
>should equal 3.86 times the square root of r times the sum of f + or -
e.
>The values are provided by the user.
>Example, when I input r = 250 and f = .70 and e = .03 I get 52.11. When
I
>input e as a negative number it still adds instead of subtracts and I
still
>get 52.11. Everything works fine except it won't subtract the value of e
if
>user inputs a negative number.


>>>if (e>=0)
>>>{s = 3.86*sqrt(r*(f+e));}
>>>else
>>>{s = 3.86*sqrt(r*(f-e));}


Maybe I'm missing something, but if e is negative, then you're
subtracting a negative, which is the same as adding a positive.

If that's not what you want, then change your code to remove the if,
and always use the first expression. Then if it adds a negative, the
value will be smaller.

--
Chris (TeamB);
 

Re:Re: What's wrong with this

Hi!
Aaron schrieb:
Quote
I hope what I develop
will make it quicker for AR's to calculate speeds, radii, etc.
It's only in the beginning stages, but hopefully it won't be much longer
until I am finished.
I don't know if I understand that correctly, but if the equation is
s = 3.86*sqrt r(f +- e)
then why don't you display both results at once?
#include <algorithm>
e = std::max(e,-e);
s1 = 3.86*sqrt(r*(f + e))
s2 = 3.86*sqrt(r*(f - e))
Then show both results.
Frank
 

Re:Re: What's wrong with this

"Aaron" < XXXX@XXXXX.COM >wrote in message
Quote
Hi Remy, I am trying to develop an easier method of collecting
data and calculating it for AR's. Trying to do all of it with a
calculator is not only confusing but it is also very time
consuming. I hope what I develop will make it quicker for
AR's to calculate speeds, radii, etc.
You do realize that many other AR calculation programs already exist, don't
you? Many ARs don't use calculators anymore, or at least not as often, for
exactly that reason - too slow, programs are faster. So I hope what you end
up making is a knock-out and offers good competition against the others :-)
Gambit
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 9/1/03
 

Re:Re: What's wrong with this

Yes, I do know that. Aside from a little developing on the side, my full
time job is police officer, and why buy a program when I can make it :)
Someone once told me that there are several car companies and several types
of soft drinks, all of which sells. Maybe, with a little luck, I might be
able to sell this to a few of my friends and aquaintances who investigate
and / or reconstructs accidents (crashes)..
Thanks as always,
Aaron
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Aaron" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...
>Hi Remy, I am trying to develop an easier method of collecting
>data and calculating it for AR's. Trying to do all of it with a
>calculator is not only confusing but it is also very time
>consuming. I hope what I develop will make it quicker for
>AR's to calculate speeds, radii, etc.

You do realize that many other AR calculation programs already exist,
don't
you? Many ARs don't use calculators anymore, or at least not as often,
for
exactly that reason - too slow, programs are faster. So I hope what you
end
up making is a knock-out and offers good competition against the others
:-)


Gambit


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 9/1/03


 

Re:Re: What's wrong with this

"Aaron" < XXXX@XXXXX.COM >wrote in message
Quote
Yes, I do know that. Aside from a little developing on the side,
my full time job is police officer, and why buy a program when
I can make it :)
Good idea. Make what works for you, and hope someone else will like it as
well. If I had more time and access to some of my AR friend's calculation
cheat sheets and stuff, I'd opt to make him a program. He's always on the
lookout for new ones to try.
Gambit
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 9/1/03