473,396 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

unsigned long long int to long double


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
Nov 15 '05 #1
5 9104
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

Nov 15 '05 #2
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
Nov 15 '05 #3
On Mon, 19 Sep 2005 05:49:28 GMT, Daniel Rudy <no****@nospam.net>
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>>
Nov 15 '05 #4
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 <no****@nospam.net>
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
Nov 15 '05 #5
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"?
Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: Richard A. Huebner | last post by:
Is the unsigned long long primitive data type supported in ANSI standard C? I've tried using it a couple of times in standard C, but to no avail. I'm using both MS VIsual C++ 6, as well as the...
10
by: jeff | last post by:
unsigned long a = ...; long b = (long)a; while a overflows, what is the result of b? Thank you.
17
by: jithoosin | last post by:
Hi, Why is the code not getting compiled ? I am using SuSe linux. Is it becuase of that ? #include<stdio.h> int main() { long long i; i = LL 9876543219; printf("%ld\n", i);
9
by: vadivel.ks | last post by:
hi, My code having unsigned long long int64_t; like that.. compile error message is long followed by long is illegal, what is the reason for it?
6
by: Ikke | last post by:
Hi everybody, Coming from a Java background, I'm used to having a "long" type and a "Long" Object around... I've recently started a simple, small C# project, and I'm looking for a way to pass...
10
by: Kenneth Brody | last post by:
Does the cast "(unsigned)" imply "(unsigned int)", or does it simply strip the signedness from the variable? In other words, given this: long l = -123; unsigned long ul = (unsigned)l; Does...
21
by: Bart C | last post by:
I've always had a problem knowing exactly how wide my integer variables were in C, and the little program below has increased my confusion. Run on 3 compilers on the same cpu (32-bit pentium),...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.