SI
SI
discoversearch

We've detected that you're using an ad content blocking browser plug-in or feature. Ads provide a critical source of revenue to the continued operation of Silicon Investor.  We ask that you disable ad blocking while on Silicon Investor in the best interests of our community.  If you are not using an ad blocker but are still receiving this message, make sure your browser's tracking protection is set to the 'standard' level.
Strategies & Market Trends : TA-Quotes Plus -- Ignore unavailable to you. Want to Upgrade?


To: Nazbuster who wrote (6412)9/7/1998 7:30:00 PM
From: Sean W. Smith  Read Replies (1) | Respond to of 11149
 
Daniel,

Your problem is caused by the implicit type casting. 1/8 means integer divide 1/8 which is 0. 1.0/8 yields .125 as you expect.
The same features are found in C and many other languages. There no explicit type casts in QP. This will work...

output="tst.lst";
float dec, fr;
dec:= 1 + .125; fr:= 1 + 1.0/8;
println symbol,",",dec,",",fr;

Sean



To: Nazbuster who wrote (6412)9/7/1998 7:31:00 PM
From: Bob Jagow  Respond to of 11149
 
Daniel,
Why don't you post the code that you are unable to write because of the 'bug' and let me judge its severity?

Hint: I consider the equality between 1/8 and 0.125 common enough knowledge to make .125 an acceptable workaround ;)

Bob
[edit] I see Sean answered your question. Missed that, even though I used a version of it recently in some qp code where I had to truncate some floats to ints.