This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Getting equivalent 'double' parsing in c++ and fortran?


> Both represent the same binary number.  You can simply verify 
> this by doing something like
>    double x, y;
>    sscanf("2.70000000000000017762568294", "%f", &x);
>    sscanf("2.70000000000000017762570000", "%f", &y);
>    printf("%80.70f\n", x - y);

Good point.  I just did a similar experiment.

I took the high-precision formatted output from when fortran parsed and printed "2.7" as a double precision number.  I supplied that printed output to my C++ program, which parsed it as a double.  The bit pattern of the resulting C++ variable was exactly the same as the bit pattern produced by having the C++ code parse "2.7".

Thanks for all the help.

- Christian

Attachment: smime.p7s
Description: S/MIME cryptographic signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]