title: Convert unsigned long long to double in C
body: <p>I realize this question could be processor dependent, but hopefully someone can point me in the right direction. For the life of me, I cannot figure out how to convert an unsigned long long int representing nanoseconds to a double representing seconds in C (I'm using a 32-bit big-endian PowerPC 405 for this particular test, and a GNU C99 compiler).</p>
  
  <p>I've tried:</p>
  
  <pre><code>unsigned long long int nanoseconds = 1234567890LLU;
  double nanoseconds_d = nanoseconds*1e-9;
  </code></pre>
  
  <p>Also:</p>
  
  <pre><code>nanoseconds_d = ((double) nanoseconds)*1e-9;
  </code></pre>
  
  <p>For both cases, I just get 0. What am I doing wrong here?</p>
  
  <p><strong>EDITED TO ADD FULL EXAMPLE</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int
  main( int argc, char *argv[] )
  {
      unsigned long long int nanoseconds = 1234567890LLU;
      double nanoseconds_d = nanoseconds * 1e-9;
      printf("%g\n", nanoseconds_d);
  
      return 0;
  }
  </code></pre>
  
  <p><strong>MAKEFILE</strong></p>
  
  <pre><code>SRCS    = simple.c    
  INCLUDE := -I$(PWD)            
  CFLAGS  := -O0 -g3 -Wall -fmessage-length=0 -mhard-float -fsigned-char -D_REENTRANT
  LIBS    := -lc
  
  OBJS = $(SRCS:.c=.o)
  PROG = $(SRCS:.c=).out
  
  all: $(PROG)
  
  $(PROG): $(OBJS)
      @echo "Linking object files with output."
      $(CC) -o $(PROG) $(OBJS) $(LIBS)
      @echo "Linking complete."
  
  $(OBJS): $(SRCS)
      @echo "Starting compilation."
      $(CC) $(CFLAGS) $(INCLUDE) -c $&lt;
      @echo "Compilation complete."   
  
  clean::
      @$(RM) *.o *.out
  </code></pre>