Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by dr_panther. 05/18/24 11:01
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (7th_zorro, dr_panther), 724 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Possible bug in Lite-C 7.80 - duplicating 'double's. #285107
08/17/09 07:36
08/17/09 07:36
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Try this code...
Code:
function whatever()
{
   double  values[6];

   values[0] = (double)2.862738448796;
   values[1] = (double)-8.642801642417908;
   diag_var("p1 = %.9f x ", (double)values[0]);	diag_var("%.9f\n", (double)values[1]);
   diag_var("p2 = %.9f x ", (double)values[2]);	diag_var("%.9f\n", (double)values[3]);

   values[2] = (double)2.86270802130925;
   values[3] = (double)-8.642629981040955;
   diag_var("p1 = %.9f x ", (double)values[0]);	diag_var("%.9f\n", (double)values[1]);
   diag_var("p2 = %.9f x ", (double)values[2]);	diag_var("%.9f\n", (double)values[3]);
}


In stage1, array is created, but not initialised cause everything will get filled manually.

In stage 2, values [0] and [1] get set, then 0,1,2,3 are all displayed. Cool.

In stage 3, values [2] and [3] get set, then 0,1,2,3 are all displayed again. WTF??.
look at the values of [0] and [1]... They now equal the values of [2] and [3]... WHY?

Am I doing something dumb?
Its not just the diag_var because if I subtract [2] and [3] from [0] and [1] I get EXACTLY zero on both subtractions.
Am I pushing the limits of the 'double' type too far? Im wondering cause the diag_var values are a little different
to what I set them to. But I put that down to double->var conversion (which is not important at this time).

I dont have a sample, but the EXACT same thing happens if I remove the array and use individually declared doubles.

Any ideas please? (and sorry if this is no bug)

PS: this code ATM lives alone inside the main function with nothing else running, so theres NO chance of anything else interfering.
Running on 7.80 commercial


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Possible bug in Lite-C 7.80 - duplicating 'double's. [Re: EvilSOB] #285109
08/17/09 07:58
08/17/09 07:58
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Var precision is limited to 3 digits behind the decimal, and those 3 digits are identical in your doubles.

http://manual.3dgamestudio.net/aarray.htm

When you want to display the full content of a double, you can not use a var function. For printing variables of any kind, look here:

http://manual.3dgamestudio.net/printf.htm


Re: Possible bug in Lite-C 7.80 - duplicating 'double's. [Re: jcl] #285114
08/17/09 08:35
08/17/09 08:35
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
But I thought by specifying the type like so
"values[0] = (double)2.862738448796;"
over-rode that limitation, and left it with that type's limitations.(in this case double)

Or are ALL 3DGS variable types limited to 3 decimal places? Even floats?
(Note: Ive never had to deal with numbers this "precice" in this ot any other language before)
So if 3DGS cant handle this precision of number (apparently being returned by a DLL)
Any suggestions on work-arounds? Precision data CANNOT be lost...

Thanks and sorry for not being a bug.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Possible bug in Lite-C 7.80 - duplicating 'double's. [Re: EvilSOB] #285117
08/17/09 08:56
08/17/09 08:56
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
A workaround for what? Your code is defining doubles, copying floats into them, and printing them as vars. That's exactly what you're getting.

Vars have only 3 digits after the decimal, no matter if they were converted from double. Look here:

http://manual.3dgamestudio.net/diag_var.htm

When you want to see the content of a variable, use printf, which accepts double variables.

BTW when you write a constant like "2.862738448796", it is a float number with 6 digits precision. lite-C has double variables, but no double constants. A cast operator like (double) can not add more digits to a number.

Re: Possible bug in Lite-C 7.80 - duplicating 'double's. [Re: jcl] #285134
08/17/09 11:07
08/17/09 11:07
Joined: Jul 2004
Posts: 1,710
MMike Offline
Serious User
MMike  Offline
Serious User

Joined: Jul 2004
Posts: 1,710
EvilSOB thanks for your feedback too about this.

printing this doesnot works on my pc..

float am=2.86270802130925;
printf("value is %f ",(double)am);

or

double am=2.86270802130925;
printf("value is %f ",am); goes with 8 decimals i guess only

or even this..

double am=2.86270802130925;
printf("value is %.20f ",am); // Forcing 20 decimals but the output when reach 7 decimals are wrong..


and of course this wont work.. because its just 6 decimals.

float value=2.862738448796;
str_for_float(test,value);
error(test);

Last edited by MMike; 08/17/09 11:27.
Re: Possible bug in Lite-C 7.80 - duplicating 'double's. [Re: EvilSOB] #285137
08/17/09 11:19
08/17/09 11:19
Joined: Jul 2004
Posts: 1,710
MMike Offline
Serious User
MMike  Offline
Serious User

Joined: Jul 2004
Posts: 1,710
Originally Posted By: EvilSOB
But I thought by specifying the type like so
"values[0] = (double)2.862738448796;"
over-rode that limitation, and left it with that type's limitations.(in this case double)

Or are ALL 3DGS variable types limited to 3 decimal places? Even floats?
(Note: Ive never had to deal with numbers this "precice" in this ot any other language before)
So if 3DGS cant handle this precision of number (apparently being returned by a DLL)
Any suggestions on work-arounds? Precision data CANNOT be lost...

Thanks and sorry for not being a bug.


how do you compile that piece of code?? my SED is returning sintax errors of cant convert at values[0]=double...
error: CONV:DOUBLE::DOUBLE

This for me is a limitation.. not a bug of function... this happened once when on space game.. but not this precise, like GPS are.

Last edited by MMike; 08/17/09 11:29.
Re: Possible bug in Lite-C 7.80 - duplicating 'double's. [Re: MMike] #285140
08/17/09 11:37
08/17/09 11:37
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
MMike: floats have a maximum precision of about 6 digits, vars 9 digits, and doubles 14 digits. There is no variable with 20 digits precision. Constants in the script are either floats or integers. When you get syntax errors, something's wrong with your version or your code.

Re: Possible bug in Lite-C 7.80 - duplicating 'double's. [Re: jcl] #285189
08/17/09 14:33
08/17/09 14:33
Joined: Apr 2009
Posts: 33
Germany
B
Bunsen Offline
Newbie
Bunsen  Offline
Newbie
B

Joined: Apr 2009
Posts: 33
Germany
EvilSOB and MMike are right. There seems to be no double type precision in Lite-C.

From Microsoft MSDN:
Quote:

Microsoft Specific

The double type contains 64 bits: 1 for sign, 11 for the exponent,
and 52 for the mantissa. Its range is +/–1.7E308 with at least
15 digits of precision.

END Microsoft Specific



Code:
#include <stdio.h>
#inlude <windows.h>

double d = 0.12345678901234;

void main()
{
    if (d == 0.12345679)
    	MessageBox(NULL, "equal", "This is wrong!", MB_OK);
    
    char buf[100];
    sprintf(buf, "%1.14f", d);
    MessageBox(NULL, buf, "Result", MB_OK);
}



Output:

Borland C++Builder: 0.12345678901234 (correct!)
Atari Lite-C: "equal" + 0.12345679104328 (wrong! last 6 digits are random)

Re: Possible bug in Lite-C 7.80 - duplicating 'double's. [Re: Bunsen] #285195
08/17/09 14:46
08/17/09 14:46
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
When you want to post something into a discussion, it might be a good idea to read the thread carefully and try to understand the issue. The reasons why your code can't work were already explained above.

You're just confusing constants and variables here. A constant is a number that you type in the script, like "0.12345667789". A variable is a placeholder for numbers. Lite-C knows double variables, but not double constants. Constants are either float or integer, dependent on whether they contain a decimal or not. Thus, they can have only a precision of 6 digits, which is the precision of a float. Please look here:

http://manual.3dgamestudio.net/aarray.htm

Hope this helps and settles this discussion.

Re: Possible bug in Lite-C 7.80 - duplicating 'double's. [Re: jcl] #285204
08/17/09 15:26
08/17/09 15:26
Joined: Apr 2009
Posts: 33
Germany
B
Bunsen Offline
Newbie
Bunsen  Offline
Newbie
B

Joined: Apr 2009
Posts: 33
Germany
Sorry, I was not aware of this limitation.

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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