Retourner au contenu associé (entrée de forum : atof : arrondi etrange)
Posté par Enzo Bricolo 🛠⚙🛠 le 06 septembre 2004 à 10:42. En réponse au message atof : arrondi etrange. Évalué à 1.
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
[^] # Re: heu...
Posté par Enzo Bricolo 🛠⚙🛠 . En réponse au message atof : arrondi etrange. Évalué à 1.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main (){
char montant[16];
strcpy(montant, "75.32");
fprintf(stderr, "(%s) -> (%e) -> (%d)\n",
montant,atof(montant)*100.0, (int )(atof(montant)*100.0));
exit(0);
}
$./test_atof
(75.32) -> (7.532000e+003) -> (7531)
Voir ce thread entre autre.
http://gcc.gnu.org/ml/gcc-bugs/1998-09/msg00584.html(...)
Enzo Bricolo