Article View: comp.std.c
Article #4388Re: converting int to float (or double)
From: Kurt Watzka
Date: Tue, 21 Nov 1995 14:14
Date: Tue, 21 Nov 1995 14:14
32 lines
1157 bytes
1157 bytes
dallaire@megatoon.com (Guy Dallaire) writes:
>Hi,
>Does that code guarantee that the value 3.0 (exactly) will be stored
>in variable a and b ?
>void test(void)
>{
> int i=3;
> float f;
> double d;
> a=i;
> b=i;
>}
Yes, sure, if a and b are declared as int somewhere above this
piece of code :-7.
Maybe you wanted to know whether they will be stored in f and d
exactly?
A numer that fits into the mantissa of a floating point number
can be represented exactly. Have a look at <float.h> and the
documentation for the constants defined in that header.
Kurt
--
| Kurt Watzka Phone : +49-89-2180-6254
| watzka@stat.uni-muenchen.de
| ua302aa@sunmail.lrz-muenchen.de
Technical Details
Message-ID:
<48sms5$rba@sparcserver.lrz-muenchen.de>Path:
arc1-ca.pugleaf.net!lrz-muenchen.de!sun2!ua302aaReferences:
<48r7sm$3hf@jersey.megatoon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!lrz-muenchen.de!sun2!ua302aa From: ua302aa@sun2.lrz-muenchen.de (Kurt Watzka) Newsgroups: comp.std.c Subject: Re: converting int to float (or double) Date: 21 Nov 1995 14:14:29 GMT Organization: Leibniz-Rechenzentrum, Muenchen (Germany) Distribution: world Message-ID: <48sms5$rba@sparcserver.lrz-muenchen.de> References: <48r7sm$3hf@jersey.megatoon.com> NNTP-Posting-Host: sun2.lrz-muenchen.de