Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 15:23

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Typumwandlungen

Discussion on Typumwandlungen within the C/C++ forum part of the Coders Den category.

Closed Thread
 
Old   #1
 
_Roman_'s Avatar
 
elite*gold: 0
Join Date: May 2010
Posts: 1,620
Received Thanks: 237
Typumwandlungen

Hallo, ich bin grad an einem kleinen Taschenrechner dran und hab eine Frage zur Rechnung mit Gleitpunktzahlen. Als Beispiel: Bei der Addition und Subtraktion definiere ich als Variablen int. Wenn jemand aber mit Gleitpunktzahlen rechnen will, muss ich ja eine Typumwandlung machen, außer ich kann Floats auch als Ganzzahlen schreiben, was ich nicht weiß. Leider verstehe ich das ganze nicht.
Kann mir bitte einer erklären, wie man nen int in einen float umwandelt oder ne andere Möglichkeit, sodass wenn jemand bei nem int 1.2 eingibt, diese Zahl dann als float gilt.
_Roman_ is offline  
Old 04/01/2013, 22:00   #2
 
.SkyneT.'s Avatar
 
elite*gold: 273
Join Date: Sep 2010
Posts: 1,831
Received Thanks: 786
Rechne doch einfach die float Zahlen zusammen, wo liegt das Problem ?
.SkyneT. is offline  
Thanks
1 User
Old 04/01/2013, 22:09   #3
 
_Roman_'s Avatar
 
elite*gold: 0
Join Date: May 2010
Posts: 1,620
Received Thanks: 237
Ich weiß ja nicht, ob man bei einer float Variable eine Ganzzahl eingeben kann.

Edit: Hat sich erledigt, es geht, danke skynet kann geclosed werden
_Roman_ is offline  
Old 04/02/2013, 13:21   #4


 
MrSm!th's Avatar
 
elite*gold: 7110
Join Date: Jun 2009
Posts: 28,904
Received Thanks: 25,394
Jede ganze Zahl kann natürlich auch eine Gleitkommazahl sein, nur nicht umgekehrt.

#closed
MrSm!th is offline  
Thanks
1 User
Closed Thread




All times are GMT +2. The time now is 15:23.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.