473,569 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Single more 'powerful' than Integer although both use same amount of bytes ???

Hi,

a Single and Integer variable each take 4 bytes.
(check on :
http://msdn.microsoft.com/library/de...rpdatatype.asp)

But how come then that the range for valid values for an integer is
-2,147,483,648 through 2,147,483,647
(OK: 2pow32 = 4,294,967,296 e09 different posibillities )

and for a single

-3.4028235E+38 through -1.401298E-45 for negative values
1.401298E-45 through 3.4028235E+38 for positive values.

so many more values with the same amount of 32 bits ????

Any logical explanation for this ?

thnx

Christian


Nov 20 '05 #1
2 1084
"Chris" <ch********@pan dora.be> schrieb
Hi,

a Single and Integer variable each take 4 bytes.
(check on :
http://msdn.microsoft.com/library/de...rpdatatype.asp)
But how come then that the range for valid values for an integer
is
-2,147,483,648 through 2,147,483,647
(OK: 2pow32 = 4,294,967,296 e09 different posibillities )

and for a single

-3.4028235E+38 through -1.401298E-45 for negative values
1.401298E-45 through 3.4028235E+38 for positive values.

so many more values with the same amount of 32 bits ????

Any logical explanation for this ?

3.4028235E+38 is a large number, but the first ~30 decimal places are zero.
In other words, in opposite to an integer value, the step size for a high
single value is not 1 but it is 1E+38, so there are "some" numbers between
missing (higher numbers->less accuracy). The total number of different
Integer values is (at least approximately) equal to the total number of
different Single values.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
Nov 20 '05 #2
* "Chris" <ch********@pan dora.be> scripsit:
and for a single

-3.4028235E+38 through -1.401298E-45 for negative values
1.401298E-45 through 3.4028235E+38 for positive values.

so many more values with the same amount of 32 bits ????


<http://research.micros oft.com/~hollasch/cgindex/coding/ieeefloat.html>
<http://support.microso ft.com/default.aspx?sc id=kb;de;42980>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

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

Similar topics

13
3665
by: Shailesh Humbad | last post by:
I wrote a short page as a quick reference to c++ integer data types. Any feedback welcome: http://www.somacon.com/blog/page11.php
6
2339
by: Everton da Silva Marques | last post by:
Hi, I need to allocate, using malloc(), a single memory block to hold two structures and a variable length string. Is it safe (portable, alignment-wise) to sum up the sizeof's of those structures and add the length of the string, as in this snippet? const char *canonname = "domain.tld";
14
1690
by: jimjim | last post by:
Hi all, Assume x is declared as char x, and a function f( ) with prototype void f(char y). Assume f( ) is invoked somewhere in the code and: 1. The f( )'s prototype is provided, then an one-byte copy of x is passed to f( ) (unix/intel platform). 2. The prototype is not provided, then a four-byte int, which contains the
4
1708
by: gregus | last post by:
Hi everyone!!! I want to read data from several files into a single buffer. How can I do this??? I have something like this: //... typedef unsigned short word; const unsigned int W_SIZE = sizeof(word); //...
2
1904
by: Chris | last post by:
Hi, a Single and Integer variable each take 4 bytes. (check on : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vagrpdatatype.asp) But how come then that the range for valid values for an integer is -2,147,483,648 through 2,147,483,647 (OK: 2pow32 = 4,294,967,296 E+09 different posibillities )
32
6333
by: Guoqi Zheng | last post by:
I am really do not know so much about byte/bit, etc. Question, if I defined a byte(), how can I add a single byte to it? what I want is that I have an array of bytes, I loop that array, look at the value of that individual byte, if that byte is what I want, then I insert it into the new byte(). How can I do it? -- Kind regards
2
1168
by: Mika M | last post by:
Lets say I need to do something like this when running sql-sentences... Private Sub InsertIntoTable(ByVal ProductID As Integer, ByVal Amount As Single) Dim sql as String = String.Format("INSERT INTO MyTable (ProductID, Amount) VALUES ({0}, {1})", ProductID, Amount) '...code continues... End Sub ....in this case problem will be "Amount"-...
35
9311
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from 500000 to 3200000 of a file whose size is say 20MB... how do i request a download which starts directly at 500000th byte... thank u cheers
59
5552
by: David Mathog | last post by:
Apologies if this is in the FAQ. I looked, but didn't find it. In a particular program the input read from a file is supposed to be: + 100 200 name1 - 101 201 name2 It is parsed by reading the + character, and then sending the remainder into fscanf() like
30
4265
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
Let's say we had a simple function for returning the amount of days in a month: unsigned DaysInMonth(unsigned const month) { switch (month) { case 8: case 3: case 5:
0
7612
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...
0
7922
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
8119
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...
1
7668
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5509
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
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
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
936
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.