473,770 Members | 2,135 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9143
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_lon g_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_lon g_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_lon g_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_lon g_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.tva r);

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 "technicall y correct" English; but since when was rock & roll "technicall y correct"?
Nov 15 '05 #6

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

Similar topics

29
19624
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 gcc compiler that comes with RedHat linux 9. If not, what data type will yield the largest unsigned integer for me? Thanks for your help,
10
17581
by: jeff | last post by:
unsigned long a = ...; long b = (long)a; while a overflows, what is the result of b? Thank you.
17
2350
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
6425
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
18130
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 a long value to a method, which only accepts an Object. Logically, I can't pass the long value so I started looking for a Long Object. But I can't seem to find it!
10
3128
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 the value of "l" get demoted to an unsigned int during the assignment, or does it remain a long? (I am on a system where
21
2650
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), sometimes int and long int are the same, and long long int is twice the width; or sometimes both long int and long long int are twice the width of int. This apparently all quite normal according to my c99 draft and c-faq.com. However it doesn't...
0
9591
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10057
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9869
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3575
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.