Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (dr_panther, 7th_zorro), 1,203 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
fractional part of number is not displayed #221626
08/15/08 07:17
08/15/08 07:17
Joined: Jun 2008
Posts: 40
pfeldman Offline OP
Newbie
pfeldman  Offline OP
Newbie

Joined: Jun 2008
Posts: 40
Perhaps I'm doing something wrong, but this certainly looks like a bug. When the code below is executed, note that the fractional part of thresh disappears, i.e., 59.99 becomes 59.00.

Thanks!

Phillip

--------------------------------------------------------

#include <acknex.h>
#include <default.c>

var x= 61.0, thresh= 59.99;

TEXT* out_txt= {
pos_x = 100; pos_y = 100;
font = "Arial#24bi";
strings= 10;
flags= VISIBLE;
}

function main() {

video_mode = 7; // create a program window of 800x600 pixels
screen_color.blue = 50; // and make its background dark blue

var i;

for (i=0; i<10; i++) {

str_cat_num( (out_txt.pstring)[i], "%0.2f", x);

if (x >= thresh) {
str_cat( (out_txt.pstring)[i], " >= ");
}
else {
str_cat( (out_txt.pstring)[i], " < ");
}

str_cat_num( (out_txt.pstring)[i], "%0.2f", thresh);

x-= 0.47;

}

}

Re: fractional part of number is not displayed [Re: pfeldman] #221666
08/15/08 11:49
08/15/08 11:49
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
You're using "var" variables here. Programming languages have different types of variables with different ranges and precision. You can find a description in the manual under "variables".

Re: fractional part of number is not displayed [Re: jcl] #221701
08/15/08 15:50
08/15/08 15:50
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline
Serious User
testDummy  Offline
Serious User
T

Joined: Oct 2004
Posts: 1,655
Is there a deep dark secret there, somewhere.
No, there isn't.
Stop looking.

Re: fractional part of number is not displayed [Re: testDummy] #221710
08/15/08 17:10
08/15/08 17:10
Joined: Jun 2008
Posts: 40
pfeldman Offline OP
Newbie
pfeldman  Offline OP
Newbie

Joined: Jun 2008
Posts: 40
The manual seems fairly clear on this:

var 4 bytes -1048577.999 to 1048576.999** 0.001

Perhaps 0.001 means something different in German? (just kidding)

It seems as though "var x= 61.0, thresh= 59.99;" actually assigns a value of 59.000 to thresh rather than 59.990.

Re: fractional part of number is not displayed [Re: pfeldman] #221712
08/15/08 17:19
08/15/08 17:19
Joined: Apr 2008
Posts: 586
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 586
Austria
Hmm, simply running your program would show you that its still 59.99.

Maybe you'r using an outdated version or something like that?



Re: fractional part of number is not displayed [Re: Petra] #222612
08/20/08 07:21
08/20/08 07:21
Joined: Jun 2008
Posts: 40
pfeldman Offline OP
Newbie
pfeldman  Offline OP
Newbie

Joined: Jun 2008
Posts: 40
Thanks, Petra. Yours was the only useful suggestion that I've received. The version that I was using was only 60 days old, but it seems as though the Conitec people have quietly fixed a lot of things in the interim. Thanks again!

Phillip


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1