473,508 Members | 2,744 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 1080
"Chris" <ch********@pandora.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********@pandora.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.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html>
<http://support.microsoft.com/default.aspx?scid=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
3657
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
2335
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...
14
1683
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...
4
1701
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 =...
2
1901
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...
32
6307
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...
2
1166
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...
35
9298
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...
59
5536
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...
30
4244
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
7228
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
7393
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...
1
7058
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
5635
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,...
1
5057
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...
0
3206
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...
0
3191
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1565
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 ...
0
426
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...

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.