double wil not display correct value's.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Paul Jelis
    New Member
    • Dec 2012
    • 1

    double wil not display correct value's.

    if I load a double number
    Code:
    VALUE=123456789;
    printf("%f \n",VALUE); // give's 123456789
    VALUE=138414/1000000;
    printf("%f \n",VALUE); // gives me 0.000000000
    I want to add a number + some decimal
    Code:
    VALUE[0]=12345678;
    VALUE[1]=.138414;
    VALUE[2]=VALUE[0]+VALUE[1];
    I don't get the expected  12345678.138414
    wat's wrong here ?
    Last edited by Rabbit; Dec 9 '12, 01:14 AM. Reason: Edited for language - removed word sh**. Please use code tags when posting code.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    This code:

    Code:
    VALUE=138414/1000000;
    gives a value of 0. 138414/1000000 is zero. These are ints and 1000000 goes into 138414 zero times.

    This code:
    Code:
    VALUE[0]=12345678;
     VALUE[1]=.138414;
     VALUE[2]=VALUE[0]+VALUE[1];
    appears to work OK but are you displaying VALUE or VALUE[2] ?

    If you are inadvertantly displaying VALUE you will see 0.0 because VALUE is an address (the name of an array is the address of the array).

    Comment

    Working...