Solving!!


#include "stdafx.h"
#include  "stdio.h"

int main(int argc, char* argv[])
{   float a;
    double b;
	long double c;
	a=0.1234567890123456789;
	b=1234567890123456.123456;
	c=1234567890123456.123456;
	printf("a=%f\n",a);
	printf("b=%f\n",b);
	printf("c=%Lf\n",c);
}



Why the fractional part of B and C is 000000.?

Started by Quennel at February 07, 2016 - 12:36 PM

Learn to debug program

Posted by Camille at November 12, 2016 - 7:36 AM

Hello, I compiled B and C output is 1234567890123456.000000, should how to debug.?

Posted by Quennel at November 20, 2016 - 7:47 AM

Posted by Quennel at December 02, 2016 - 7:59 AM

The result, because you give B and C data over the double and long double said. As for why the decimal part is 0, this would not have struggled, as long as you know the program has a problem on the line.

Posted by Roy at December 09, 2016 - 8:41 AM

Length: 16 bit decimal
No number of words, a total of 17
In your B, C the length is more than the upper limit, so the content does not belong to B and C
May happen to be 0? Or is this position by the 0 initialization?

Posted by Jo at December 12, 2016 - 9:06 AM

Beyond the effective range. . . . . . .

Posted by Lyle at December 27, 2016 - 9:25 AM

The integer part of the effective precision floating-point type occupied the entire
Because the integer part can be represented accurately, so the fractional part is all 0

Posted by Ricky at January 01, 2017 - 10:16 AM

Posted by Samson at January 03, 2017 - 10:39 AM

#include <stdio.h>
int main() {
    float a;
    double b;
    long double c;

    a=0.123456f;
    b=1.23456789012345e1;
    c=1.23456789012345e1;
    printf("a=%.6g\n",a);
    printf("b=%.15lg\n",b);
    printf("c=%.15lg\n",c);
    return 0;
}


Reference resources:
include\float.h
...
#define DBL_DIG         15                      /* # of decimal digits of precision */
#define DBL_EPSILON     2.2204460492503131e-016 /* smallest such that 1.0+DBL_EPSILON != 1.0 */
#define DBL_MANT_DIG    53                      /* # of bits in mantissa */
#define DBL_MAX         1.7976931348623158e+308 /* max value */
#define DBL_MAX_10_EXP  308                     /* max decimal exponent */
#define DBL_MAX_EXP     1024                    /* max binary exponent */
#define DBL_MIN         2.2250738585072014e-308 /* min positive value */
#define DBL_MIN_10_EXP  (-307)                  /* min decimal exponent */
#define DBL_MIN_EXP     (-1021)                 /* min binary exponent */
#define _DBL_RADIX      2                       /* exponent radix */
#define _DBL_ROUNDS     1                       /* addition rounding: near */

#define FLT_DIG         6                       /* # of decimal digits of precision */
#define FLT_EPSILON     1.192092896e-07F        /* smallest such that 1.0+FLT_EPSILON != 1.0 */
#define FLT_GUARD       0
#define FLT_MANT_DIG    24                      /* # of bits in mantissa */
#define FLT_MAX         3.402823466e+38F        /* max value */
#define FLT_MAX_10_EXP  38                      /* max decimal exponent */
#define FLT_MAX_EXP     128                     /* max binary exponent */
#define FLT_MIN         1.175494351e-38F        /* min positive value */
#define FLT_MIN_10_EXP  (-37)                   /* min decimal exponent */
#define FLT_MIN_EXP     (-125)                  /* min binary exponent */
#define FLT_NORMALIZE   0
#define FLT_RADIX       2                       /* exponent radix */
#define FLT_ROUNDS      1                       /* addition rounding: near */

#define LDBL_DIG        DBL_DIG                 /* # of decimal digits of precision */
#define LDBL_EPSILON    DBL_EPSILON             /* smallest such that 1.0+LDBL_EPSILON != 1.0 */
#define LDBL_MANT_DIG   DBL_MANT_DIG            /* # of bits in mantissa */
#define LDBL_MAX        DBL_MAX                 /* max value */
#define LDBL_MAX_10_EXP DBL_MAX_10_EXP          /* max decimal exponent */
#define LDBL_MAX_EXP    DBL_MAX_EXP             /* max binary exponent */
#define LDBL_MIN        DBL_MIN                 /* min positive value */
#define LDBL_MIN_10_EXP DBL_MIN_10_EXP          /* min decimal exponent */
#define LDBL_MIN_EXP    DBL_MIN_EXP             /* min binary exponent */
#define _LDBL_RADIX     DBL_RADIX               /* exponent radix */
#define _LDBL_ROUNDS    DBL_ROUNDS              /* addition rounding: near */
...

Posted by Angelina at January 10, 2017 - 11:19 AM

Feeling or length of the problem

Posted by Hamiltion at January 11, 2017 - 12:01 PM