unsigned long long int to long double

Discussion in 'C Programming' started by Daniel Rudy, Sep 19, 2005.

  1. Daniel Rudy

    Daniel Rudy Guest

    How does one covert a interger number in a unsigned long long int
    (64-bit) to long double (80-bit) storage? I looked at math.h and I
    found function that convert double to long long, but didn't really see
    anything that I could use.


    --
    Daniel Rudy

    Email address has been base64 encoded to reduce spam
    Decode email address using b64decode or uudecode -m
    Daniel Rudy, Sep 19, 2005
    #1
    1. Advertising

  2. Daniel Rudy wrote:
    > How does one covert a interger number in a unsigned long long int
    > (64-bit) to long double (80-bit) storage?


    my_long_double = my_unsigned_long_long_int;

    > I looked at math.h and I found function that convert double to long
    > long, but didn't really see anything that I could use.


    Which function are you talking about?

    Note, if the bit size of your types actually matter, then comp.lang.c
    is probably not the best group to post to; you would be better off
    asking a platform/compiler specific group.

    --
    Peter
    Peter Nilsson, Sep 19, 2005
    #2
    1. Advertising

  3. Daniel Rudy

    Daniel Rudy Guest

    At about the time of 9/18/2005 8:42 PM, Peter Nilsson stated the following:

    > Daniel Rudy wrote:
    >
    >>How does one covert a interger number in a unsigned long long int
    >>(64-bit) to long double (80-bit) storage?

    >
    >
    > my_long_double = my_unsigned_long_long_int;
    >
    >


    It's that easy? Whoa...Thanks.

    >>I looked at math.h and I found function that convert double to long
    >>long, but didn't really see anything that I could use.

    >
    >
    > Which function are you talking about?


    sqrt();

    > Note, if the bit size of your types actually matter, then comp.lang.c
    > is probably not the best group to post to; you would be better off
    > asking a platform/compiler specific group.


    I know that the interger type matters because it's a counter. I'm not
    sure about the floating point type though.



    --
    Daniel Rudy

    Email address has been base64 encoded to reduce spam
    Decode email address using b64decode or uudecode -m
    Daniel Rudy, Sep 19, 2005
    #3
  4. On Mon, 19 Sep 2005 05:49:28 GMT, Daniel Rudy <>
    wrote:

    >At about the time of 9/18/2005 8:42 PM, Peter Nilsson stated the following:
    >
    >> Daniel Rudy wrote:
    >>
    >>>How does one covert a interger number in a unsigned long long int
    >>>(64-bit) to long double (80-bit) storage?

    >>
    >>
    >> my_long_double = my_unsigned_long_long_int;
    >>
    >>

    >
    >It's that easy? Whoa...Thanks.
    >
    >>>I looked at math.h and I found function that convert double to long
    >>>long, but didn't really see anything that I could use.

    >>
    >>
    >> Which function are you talking about?

    >
    >sqrt();


    sqrt doesn't convert anything, let alone double to long long. sqrt
    returns a double. sqrtl returns a long double.

    >
    >> Note, if the bit size of your types actually matter, then comp.lang.c
    >> is probably not the best group to post to; you would be better off
    >> asking a platform/compiler specific group.

    >
    >I know that the interger type matters because it's a counter. I'm not
    >sure about the floating point type though.


    The fact that it is a counter only matters if you are counting things
    in excess of 2+ billion. Possible if you are working with stars in
    galaxies or grains of sand but why do you think the bit size matters?


    <<Remove the del for email>>
    Barry Schwarz, Sep 19, 2005
    #4
  5. Daniel Rudy

    Daniel Rudy Guest

    At about the time of 9/18/2005 11:48 PM, Barry Schwarz stated the following:
    > On Mon, 19 Sep 2005 05:49:28 GMT, Daniel Rudy <>
    > wrote:
    >
    >
    >>At about the time of 9/18/2005 8:42 PM, Peter Nilsson stated the following:
    >>
    >>
    >>>Daniel Rudy wrote:
    >>>
    >>>
    >>>>How does one covert a interger number in a unsigned long long int
    >>>>(64-bit) to long double (80-bit) storage?
    >>>
    >>>
    >>> my_long_double = my_unsigned_long_long_int;
    >>>
    >>>

    >>
    >>It's that easy? Whoa...Thanks.
    >>
    >>
    >>>>I looked at math.h and I found function that convert double to long
    >>>>long, but didn't really see anything that I could use.
    >>>
    >>>
    >>>Which function are you talking about?

    >>
    >>sqrt();

    >
    >
    > sqrt doesn't convert anything, let alone double to long long. sqrt
    > returns a double. sqrtl returns a long double.
    >
    >


    The code in question is this:

    rstats.tavg = acc1 / count;
    rstats.tvar = (acc2 / count) - (rstats.tavg * rstats.tavg);
    rstats.tdev = sqrt(rstats.tvar);

    This code takes values that were collected earlier and computes average,
    variance, and standard deviation. The acc1 and acc2 variables are
    defined as uint64 (unsigned long long int) while everything else is
    defined as a ldfloat (long double). I do need a square root function,
    but I used sqrt as a place holder until I can find the sqrt function
    that I really need. I do thank you for telling me that sqrtl returns a
    long double.

    >>>Note, if the bit size of your types actually matter, then comp.lang.c
    >>>is probably not the best group to post to; you would be better off
    >>>asking a platform/compiler specific group.

    >>
    >>I know that the interger type matters because it's a counter. I'm not
    >>sure about the floating point type though.

    >
    >
    > The fact that it is a counter only matters if you are counting things
    > in excess of 2+ billion. Possible if you are working with stars in
    > galaxies or grains of sand but why do you think the bit size matters?
    >
    >


    It probably doesn't, but I threw those numbers in there anyways. The
    real questions were how to convert a unsigned long long int to a long
    double, and if there was a sqrt function that returned a long double.

    > <<Remove the del for email>>



    --
    Daniel Rudy

    Email address has been base64 encoded to reduce spam
    Decode email address using b64decode or uudecode -m
    Daniel Rudy, Sep 19, 2005
    #5
  6. Groovy hepcat Daniel Rudy was jivin' on Mon, 19 Sep 2005 05:49:28 GMT
    in comp.lang.c.
    Re: unsigned long long int to long double's a cool scene! Dig it!

    >At about the time of 9/18/2005 8:42 PM, Peter Nilsson stated the following:
    >> Daniel Rudy wrote:
    >>
    >>>I looked at math.h and I found function that convert double to long
    >>>long, but didn't really see anything that I could use.

    >>
    >> Which function are you talking about?

    >
    >sqrt();


    You mean the sqrt() function that has the following signature?

    double sqrt(double);

    You mean the sqrt() function that returns the square root of its
    input? You mean you really think this function converts a double to a
    long long?
    Tell me, is there insanity in your family? :)

    --

    Dig the even newer still, yet more improved, sig!

    http://alphalink.com.au/~phaywood/
    "Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
    I know it's not "technically correct" English; but since when was rock & roll "technically correct"?
    Peter Shaggy Haywood, Sep 20, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Timo Freiberger
    Replies:
    3
    Views:
    919
    Bob Hairgrove
    Oct 30, 2004
  2. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    644
    Eric Sosman
    Jul 8, 2003
  3. CFAN
    Replies:
    6
    Views:
    800
    Tor Rustad
    Apr 4, 2007
  4. pereges

    Promoting unsigned long int to long int

    pereges, Jun 30, 2008, in forum: C Programming
    Replies:
    112
    Views:
    2,017
    David Thompson
    Jul 28, 2008
  5. pozz
    Replies:
    12
    Views:
    699
    Tim Rentsch
    Mar 20, 2011
Loading...

Share This Page