Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Missing something very simple on my code
Updated May 23, 2010
Top Posters
looks_one
sharp2be
with 3 posts (0 thanks)
looks_two
sam028
with 1 posts (2 thanks)
looks_3
Quick Summary
with 1 posts (0 thanks)
looks_4
Big Mike
with 1 posts (1 thanks)
trending_up
2,821 views
thumb_up
3 thanks given
group
2 followers
forum
5 posts
attach_file
0 attachments
Missing something very simple on my code
May 21st, 2010, 02:55 PM
Canada
Experience: Advanced
Platform: NT, TS
Broker: Amp
Trading: ES
Posts: 57 since Sep 2009
Thanks Given: 1
Thanks Received: 69
Hi everyone , I know I'm missing something very simple here but I'm trying to print the result of a simple calculation and it always prints zero... can anyone help please:
here's my snippet:
Code:
Code
int countWins;
int countAllTrades;
countWins = 10;
countAllTrades = 20;
winPct = 100*(countWins/countAllTrades);
Print("---- probabilities :-) ");
Print("# countAllTrades = " + countAllTrades.ToString() +
", countWins = " + countWins + " (" + winPct.ToString() + ")" );
and here's what is printing..
---- probabilities :-)
# countAllTrades = 20, countWins = 10 (0)
not sure why I'm getting zero for the winPct...
Can anyone help please?
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
May 21st, 2010, 03:21 PM
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629
Because Int/Int => Int
So:
Code
winPct = 100 * countWins / countAllTrades ;
is better.
Or, if you want to keep the useless/confusing () :
Code
winPct = 100 *((float) countWins /(float) countAllTrades );
Success requires no deodorant! (Sun Tzu)
May 21st, 2010, 03:27 PM
Canada
Experience: Advanced
Platform: NT, TS
Broker: Amp
Trading: ES
Posts: 57 since Sep 2009
Thanks Given: 1
Thanks Received: 69
sam028
Because Int/Int => Int
So:
Code
winPct = 100 * countWins / countAllTrades ;
is better.
Or, if you want to keep the useless/confusing ()
:
Code
winPct = 100 *((float) countWins /(float) countAllTrades );
Sam -- excellent ! I'm back on business. Thank you so much.
May 21st, 2010, 07:05 PM
Manta, Ecuador
Site Administrator Developer Swing Trader
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,397 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,537
sharp2be
Sam --
excellent ! I'm back on business. Thank you so much.
Please remember to press the Thanks button when you find something useful, as a reward to the poster
Mike
May 22nd, 2010, 10:40 PM
Canada
Experience: Advanced
Platform: NT, TS
Broker: Amp
Trading: ES
Posts: 57 since Sep 2009
Thanks Given: 1
Thanks Received: 69
Big Mike
Please remember to press the Thanks button when you find something useful, as a reward to the poster
Mike
Did it now. Thanks.
Last Updated on May 22, 2010