Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Floats (noob question)

Author
Message
Michael P
18
Years of Service
User Offline
Joined: 6th Mar 2006
Location: London (UK)
Posted: 15th Feb 2008 17:11
I'm pretty confused as far as floats are concerned. I'm trying to define a float as below:



Why do I see "warning C4305: 'initializing' : truncation from 'double' to 'float'"? Why does the float end up being 0.1000000 instead?
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 15th Feb 2008 17:21
Adding an 'f' to the end of the number specifies that you want a single-precision float, which will stop that warning.

Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 15th Feb 2008 17:21 Edited at: 15th Feb 2008 17:23
Easy one, for float number asignation, calculus, etc, always end the figure with an 'f', like



otherwise the number is considered to be a double float, so it warns you about the conversion.

[Edit: lol, same minute Benjamin]

Login to post a reply

Server time is: 2024-09-29 11:25:38
Your offset time is: 2024-09-29 11:25:38