Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by madpower2000. 07/22/26 14:01
ZorroGPT
by TipmyPip. 07/21/26 17:54
New Zorro version 3.11
by jcl. 07/21/26 13:42
Lapsa's very own thread
by Lapsa. 07/18/26 13:40
Purchase A8 full licence version
by ukgamer. 07/17/26 05:52
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
2 registered members (AndrewAMD, 1 invisible), 9,798 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
riggi89, shuhari, KD1990, Ephraim, Student_64151
19223 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
var conversion issue? #247100
01/19/09 02:23
01/19/09 02:23
Joined: Dec 2008
Posts: 43
D
DavidM Offline OP
Newbie
DavidM  Offline OP
Newbie
D

Joined: Dec 2008
Posts: 43
Code:
	var test = 100.5;
	printf( "Test %i", (int) test );
	float test2 = floatv(test);
	printf( "Test2 %d", (double)test2 );
	float test3 = test;
	printf( "Test3 %d", (double)test3 );


Results:
Test: 100
Test2: 0
Test3: 0

I have tried this test with fprintf(..) and get the same results.

Why are the conversions failing?

A7 version 7.60

Re: var conversion issue? [Re: DavidM] #247102
01/19/09 02:54
01/19/09 02:54
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
I'll be interested in this answer too, Ive only ever found
printf( "Test %.0f", (anynum) test); to actually work.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: var conversion issue? [Re: EvilSOB] #247168
01/19/09 09:46
01/19/09 09:46
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
%.0f is for the var display. The conversion to int seems to work fine. Double is not %d, but %f or %u. %d is also int.

http://www.cplusplus.com/reference/clibrary/cstdio/printf.html


Click and join the 3dgs irc community!
Room: #3dgs

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

Gamestudio download | 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