473,544 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

format of double and __int64

Hi,
How is a double value stored in 8 bytes ? Or what is the format ?
How is it different from __int64 ? How is __int64 stored in 8 bytes.
Please do reply.

regards,
Jayesh

Nov 28 '05 #1
8 4184
"Jayesh" <ja***********@ gmail.com> wrote:
How is a double value stored in 8 bytes ? Or what is the format ?
Only your implementation' s documentation can tell you. In fact, only
your docs can tell you _whether_ a double is stored in 8 bytes, let
alone how.
How is it different from __int64 ? How is __int64 stored in 8 bytes.
There is no such thing as an __int64 in ISO C, but where it is an
extension it probably is an integer type. double is a floating point
type. The two are very different. Integer types are stored as a number
of value bits, a sign bit if it's a signed type, and possibly a number
of padding bits. Floating point types are stored as a sign bit
(always!), a mantissa, and an exponent.
Please do reply.


No. Won't. Refuse to. So there.

Richard
Nov 28 '05 #2
> How is a double value stored in 8 bytes ?

Who says a double takes 8 bytes? That is not guaranteed, although
it is a popular implementation.
Or what is the format ?
Any format the implementation wants. The double-you aitch ay tee
format is not particularly popular.
How is it different from __int64 ?
double is a type in standard C. __int64 is not.
How is __int64 stored in 8 bytes.


Types that do not exist aren't stored.

Gordon L. Burditt
Nov 28 '05 #3
"Jayesh" <ja***********@ gmail.com> writes:
Hi,
How is a double value stored in 8 bytes ?
First byte first, last byte last, and everyting else in between.

How a double is stored can vary from one implementation to the
other, and it doesn't even have to be 8 bytes (whatever a byte
means...)

Or what is the format ? In printf "%f" or "%g" perhaps?
How is it different from __int64 ?


There is no type named __int64 in C. (At least not in C90). Anyway,
a 64 bit integer would store integer value, and double floating
point values, so the same bit pattern would most likely represent
different values. One exception might be zero, which might be
represented as all bits zero both for integers and floating point
values, but even that is not guarantied.

/Niklas Norrthon
Nov 28 '05 #4
Thanks Richard.
Ok, so double is a floating poind type and is stored as sign
bit,mantissa and an exponent. So for a double value is there any fixed
format like these many bits for mantissa and these many bits for
exponent ?
Similarly how is the long long variable stored ? Is it a sign bit
followed by the value bits ?
( I use visual c++ compiler or cc or CC and always confuse with whether
the type belongs to C or C++ :( )

// Jayesh

Nov 29 '05 #5
On 29 Nov 2005 01:42:13 -0800, in comp.lang.c , "Jayesh"
<ja***********@ gmail.com> wrote:
Thanks Richard.
Ok, so double is a floating poind type and is stored as sign
bit,mantissa and an exponent. So for a double value is there any fixed
format like these many bits for mantissa and these many bits for
exponent ?
No. However many C implementations will use IEEE 754 format.
Similarly how is the long long variable stored ? Is it a sign bit
followed by the value bits ?


Whatever is most convenient for the platform. Typically it might well
be as you describe, but as far as I know, C makes no requirements.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt >

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 29 '05 #6


Jayesh wrote On 11/29/05 04:42,:
Thanks Richard.
Ok, so double is a floating poind type and is stored as sign
bit,mantissa and an exponent. So for a double value is there any fixed
format like these many bits for mantissa and these many bits for
exponent ?


The C Standard does not guarantee any particular
values. However, the Standard requires the implementation
to document its values through macros defined in <float.h>.
You seem to be interested in FLT_RADIX, DBL_MANT_DIG,
DBL_MIN_EXP, and DBL_MAX_EXP.

--
Er*********@sun .com

Nov 29 '05 #7
Mark McIntyre <ma**********@s pamcop.net> writes:
On 29 Nov 2005 01:42:13 -0800, in comp.lang.c , "Jayesh"
<ja***********@ gmail.com> wrote:

[...]
Similarly how is the long long variable stored ? Is it a sign bit
followed by the value bits ?


Whatever is most convenient for the platform. Typically it might well
be as you describe, but as far as I know, C makes no requirements.


Actually, there are some requirements. Since long long is a signed
type, it's guaranteed to be represented as one of two's-complement,
one's-complement, or signed-magnitude. There are also some
requirements about the value bits matching between any signed integer
type and the corresponding unsigned type. And there be padding bits
that don't contribute to the value and/or that can introduce trap
representations .

But for the most part, you don't really need to know. Most operators
are defined to work on the values of the operands, not on their
representation.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 29 '05 #8
Jayesh wrote:
Hi,
How is a double value stored in 8 bytes ? Or what is the format ?
How is it different from __int64 ? How is __int64 stored in 8 bytes.
Please do reply.

regards,
Jayesh

You've received all valid responses above this one. C won't give you the
answer. The double is stored in 8 bytes (64 bits) on my system too.
Something like this..

(64-bit double)
6 5 4 3 2 1
321098765432109 876543210987654 321098765432109 876543210987654 3210
- 1-bit sign (1 == negative)
----------- 11-bit exponent (unsigned)
53-bit mantissa -----------------------------------------------------

I hope this doesn't wrapup in your newsreader or that you can otherwise
straighten it out.

This is really Off Topic in clc. Shame on me.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 29 '05 #9

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

Similar topics

2
4764
by: Matt Whelan | last post by:
Supposedly, recent versions of SWIG can be made to work with MS VC++'s non-standard integer data types. According to a recent SWIG ChangeLog entry: %apply long long { __int64 }; should make Swig happy. But it doesn't. I get Syntax Errors on each line where __int64 appears. Am I missing something? I'm new to SWIG (but not to Python...
6
6927
by: Lionel B | last post by:
Running VC++ 6 under Win2K on i386. I would like to assign a (compile-time) constant that resolves to a quiet NaN (of type double) I can assign a quiet NaN to a *variable* (of type const double, say) by eg.: const double qnan = fmod(1.0,0.0);
8
3207
by: Philipp | last post by:
Hello, I would like to print (cout) the binary representation of a double. ie the values of the bytes 1-8. A typical output would be something like (in hex) ff af 12 d3 ab 9f 3c 00 Is there a function which does this or anything approaching? I read that on win32 the representation of 8byte double is byte1 byte2 byte3 ...
12
20277
by: __frank__ | last post by:
Which format I have to use in scanf, to format a long long int (64bits int __int64 in MS VC++). Thanks in advance
1
1686
by: Jesse Hose | last post by:
I get odd behavior in the debugger with the following code. The output of the program itself is correct, but when I add the g_bad_int64_max and g_bad_int64_min to the watch window they show values of -1 and 0 repsectively. This only happens when initializing a const __int64 in global scope with a literal constant. I fooled around with the...
4
7788
by: Kio | last post by:
Hi, For example: 1 __int64 fib4(__int64 n) 2 { 3 if ((n==1) || (n==2)) return 1; 4 else return (fib(n-1)+fib(n-2)); 5 }
8
5441
by: abdul_n_khan | last post by:
Hello, I have a basic question related to datatypes. I am trying to read a value using Microsoft's ADO recordset from a field (lets call it 'Price') with datatype decimal(19,6) => 19 = Precision, 6 = Scale 1) When I read this field into float datatype. I get a value 1.9000, which is correct. But when I read its value in a double datatype...
19
4100
by: glchin | last post by:
Does a compiler guarantee that the variable w below is placed on an eight-byte aligned address? void myFunction( long iFreq ) { const double w = two_pi * iFreq; ... ... }
29
9928
by: Kenzogio | last post by:
Hi, I have a struct "allmsg" and him member : unsigned char card_number; //16 allmsg.card_number
0
7431
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...
0
7617
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. ...
0
7779
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...
0
7714
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...
0
5920
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5305
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3424
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...
1
1848
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
674
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...

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.