🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: de.comp.lang.c++
Article #1945

Problem mit float

#1945
From: Steve
Date: Wed, 27 Mar 1996 18:05
14 lines
897 bytes
Hallo,

ich habe ein kleines Problem:

Ich finde keine Funktion mit der ich den Vor- und Nachkommstellenanteil eines float's in zwei versch. int speichern kann.

Bisher habe ich es so versucht (direkte Typ-Umwandlung), aber dann rundet der Computer manchmal die Zahl:
  float mein_float = 2.5;
  int vor = (int)mein_float;
  int nach = ((float)vor-mein_float)*100; // auf zwei Stellen genau

Vielen Dank im vorraus,

Stephan
Technical Details
Message-ID: <4jc01h$3hq@news00.btx.dtag.de>
Path: arc1-ca.pugleaf.net!news00.btx.dtag.de!not-for-mail

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news00.btx.dtag.de!not-for-mail
From: Stephan.Hesmer@t-online.de (Steve)
Newsgroups: de.comp.lang.c++
Subject: Problem mit float
Date: 27 Mar 1996 18:05:36 GMT
Organization: Telekom Online Internet Gateway
Message-ID: <4jc01h$3hq@news00.btx.dtag.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Sender: 0703231844-0002@t-online.de (Stephan Hesmer)
X-Newsreader: Forte Free Agent 1.0.82