הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Question
Wednesday, January 27, 2010 11:58 AM
is it ever possible for a dictionary to hold more than 2147483647 items?
which exception do we get if we try to add to a dictionary with already 2147483647 items?
All replies (17)
Wednesday, January 27, 2010 8:32 PM ✅Answered
You are not going to create a dictionary of 2 billion entries.
You are most likely running out of memory because you hit the default maximum amount of memory allocated to a 32 bit application, 512 MBytes.
Mark the best replies as answers. "Fooling computers since 1971."
Thursday, January 28, 2010 1:51 AM ✅Answered | 1 vote
btw are supercomputers capable of creating more than 2b booleans?
Hi,
I guess so as supercomputers will use more memory and certainly more than one processor.
But any computer, super or not is limited by how many bits at a time the processor can handle.
So super computers may be 64 bit or 128 bit, who knows?
I have not heard of Intel or AMD or Motorola producing 128 bit processors.
Are there any other processor manufacturers that anyone knows about?
Although I guess a 64 bit processor could juggle two X ( 64 bit long data words ) in some operations I guess?
In a similar fashion to how Vb.Net and a 32 bit processor handles
a LONG ( Int64 ) or a ULONG ( Uint64 ).
When it comes to mathematics with very long numbers or extremely long numbers, programs are often written to deal
with those numbers as separate digits in an array or as part of a string, just so you know.
:-)
I mean Pi has been calculated to lots of decimal places, as has e and there are computers calculating the next prime number!!
2147483646 to someone in the U.K. is not 2 billion and whatever, it is
2 thousand 147 million, 483 thousand, 646
A U.K. billion is a million X a million or 1,000,000 X 1,000,000 so a billion is 1,000,000,000,000
Either way I will never have that many pennies or cents!!
You could represent 2 billion or 2,000,000,000 booleans in 250000000 bytes or 244140.625 Kb or
238.4185791015625 Mb on a hard-disk-drive. Just use the individual bits!!
Regards,
John
Wednesday, January 27, 2010 6:37 PM
I would recommend testing this scenario to see what happens. If there is a limitation to this class with respect the maximum value of a signed 32-bit integer then I'm not aware of it.Paul ~~~~ Microsoft MVP (Visual Basic)
Wednesday, January 27, 2010 8:15 PM
anyway i was talking about the System.Collections.Generic.Dictionary and related stuff within System.Collections
i couldn't test it, i get OutOfMemoryException even before i could hit 2147483647 booleans (ubound 2147483646)
Wednesday, January 27, 2010 8:34 PM | 1 vote
The ICollection interface has a LongCount property that is Int64. The Interface returns an error of OverflowException if the number of elements in source is larger than MaxValue (the size of Int32). That implies that the number of elements could be larger than MaxValue, even though some methods will return errors if you try to use them.
Wednesday, January 27, 2010 11:03 PM
btw are supercomputers capable of creating more than 2b booleans?
Thursday, January 28, 2010 4:44 AM
cool thanks for the info
Thursday, January 28, 2010 5:32 AM
Hi Pacerier,
Do you need and example of setting and unsetting individual bits in a BYTE or do you know how to do it?
Regards,
John
Thursday, January 28, 2010 6:02 AM
Supercomputers are more determid by the quantity of different instructions it has.
A microsocomputer as used on MicroSoft Operating systems has a very limited instruction set but a hich speed cycle time so calculations can be done by repeat adding and subtracting.
A micro computer has accoording to that a very limited register.
Supercomputers don't have those limitations, it are not microcomputer processors like the ones from Intel and AMD.
By the waym, how much you can store is of course beside the size of the register (not registry) completely depended from the amount of memory that is available.Success
Cor
Thursday, January 28, 2010 6:27 AM
Supercomputers are more determid by the quantity of different instructions it has.
Some of the largest and fastest computers in the world have a small instruction set compared to Intel processors.
A microsocomputer as used on MicroSoft Operating systems has a very limited instruction set but a hich speed cycle time so calculations can be done by repeat adding and subtracting.
The x86 instruction set is actually one of the most complex in common use.
By the waym, how much you can store is of course beside the size of the register (not registry) completely depended from the amount of memory that is available.
No. It is dependant on the logical address space of the CPU and how that space is made available to applications. The logical address space is not the same as the CPU register width. Disk space can always make up for limited RAM.
Thursday, January 28, 2010 7:31 AM
Supercomputers are more determid by the quantity of different instructions it has.
Some of the largest and fastest computers in the world have a small instruction set compared to Intel processors.
A microsocomputer as used on MicroSoft Operating systems has a very limited instruction set but a hich speed cycle time so calculations can be done by repeat adding and subtracting.
The x86 instruction set is actually one of the most complex in common use.
By the waym, how much you can store is of course beside the size of the register (not registry) completely depended from the amount of memory that is available.
No. It is dependant on the logical address space of the CPU and how that space is made available to applications. The logical address space is not the same as the CPU register width. Disk space can always make up for limited RAM.
And?
Did I write something else than you beside the last one, which I simply disagree.
Beside that, open for a discussion a discussion thread, I was only answering a question.
By the way, can you tell me for what supercomputer you have created program code for, then I know what you are referencing about?
Success
Cor
Thursday, January 28, 2010 1:34 PM
You are not going to create a dictionary of 2 billion entries.
**You are most likely running out of memory because you hit the default maximum amount of memory allocated to a 32 bit application, 512 MBytes. **
Mark the best replies as answers. "Fooling computers since 1971."
Mark the best replies as answers. "Fooling computers since 1971."
Thursday, January 28, 2010 1:55 PM
anyway i was talking about the System.Collections.Generic.Dictionary and related stuff within System.Collections
i couldn't test it, i get OutOfMemoryException even before i could hit 2147483647 booleans (ubound 2147483646)
Unless this is an academic question then Rudedog2 has your answer. It's a limit that you will not likely ever encounter in your code because of other constraints, specifically physical memory and performance.Paul ~~~~ Microsoft MVP (Visual Basic)
Thursday, January 28, 2010 10:24 PM
sorry i don't really understand what unsetting individual bits in a byte means
Tuesday, February 2, 2010 7:15 AM | 1 vote
sorry i don't really understand what unsetting individual bits in a byte means
Hi Pacerier,
If you set a bit it means setting it to a 1.
If you unset or reset it it means to make it a zero again.
Sorry, it was my bad use of English. The word reset is more appropriate.
Anyway this code with one button on a FORM demonstrates resetting
bits back to zero starting form the right-hand side of a BYTE having 8 bits.
( According to one forum member, He would discuss at length or argue that not all bytes have 8 bits,
but that is another matter. Hello Andrew!! )
As a BOOLEAN is TRUE or FALSE, in a similar fashion a bit is a 1 or a zero so in just one 64 bit value ( an Int64 also called a LONG )
you could represent 64 boolean values if you wanted to do it like that?
You would only need ( 2 billion / 64 ) lots of Int64's to do it!! 2,000,000,000 / 64 = 31250000 of them.
If your billion is a UK billion.>> 2,000,000,000,000 / 64 = 31250000000 of them.
Regards,
John
Option Strict On
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim aByte As Byte = Convert.ToByte(255)
'Show the value in binary.>>
Display(aByte)
'Reset the bit representing 1.>>
aByte = CByte(aByte Xor 1)
'Show the value in binary.>>
Display(aByte)
'Reset the bit representing 2.>>
aByte = CByte(aByte Xor 2)
'Show the value in binary.>>
Display(aByte)
'Reset the bit representing 4.>>
aByte = CByte(aByte Xor 4)
'Show the value in binary.>>
Display(aByte)
'Reset the bit representing 8.>>
aByte = CByte(aByte Xor 8)
'Show the value in binary.>>
Display(aByte)
'Reset the bit representing 16.>>
aByte = CByte(aByte Xor 16)
'Show the value in binary.>>
Display(aByte)
'Reset the bit representing 32.>>
aByte = CByte(aByte Xor 32)
'Show the value in binary.>>
Display(aByte)
'Reset the bit representing 64.>>
aByte = CByte(aByte Xor 64)
'Show the value in binary.>>
Display(aByte)
'Reset the bit representing 128.>>
aByte = CByte(aByte Xor 128)
'Show the value in binary.>>
Display(aByte)
End Sub
Private Sub Display(ByVal aByte As Byte)
MessageBox.Show(Convert.ToString(aByte, 2).PadLeft(8, "0"c))
End Sub
End Class
Tuesday, February 2, 2010 10:48 AM
cool thanks for the info
Tuesday, February 2, 2010 3:42 PM
Hi Pacerier,
Your welcome. :-D
I forgot to mention that if you XOR again on any one of the bits it will set it again as XOR is Exclusive Or.
So think of XOR as a way of toggling bits in a value.
Here is the above code again with one of the bits set using XOR after the zero value is reached.
That just makes it easier to see it as a 1.
:-)
Regards,
John
Option Strict On
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim aByte As Byte = Convert.ToByte(255)
'Show the value in binary.>>
Display(aByte)
'Reset the bit representing 1.>>
aByte = CByte(aByte Xor 1)
'Show the value in binary.>>
Display(aByte)
'Reset the bit representing 2.>>
aByte = CByte(aByte Xor 2)
'Show the value in binary.>>
Display(aByte)
'Reset the bit representing 4.>>
aByte = CByte(aByte Xor 4)
'Show the value in binary.>>
Display(aByte)
'Reset the bit representing 8.>>
aByte = CByte(aByte Xor 8)
'Show the value in binary.>>
Display(aByte)
'Reset the bit representing 16.>>
aByte = CByte(aByte Xor 16)
'Show the value in binary.>>
Display(aByte)
'Reset the bit representing 32.>>
aByte = CByte(aByte Xor 32)
'Show the value in binary.>>
Display(aByte)
'Reset the bit representing 64.>>
aByte = CByte(aByte Xor 64)
'Show the value in binary.>>
Display(aByte)
'Reset the bit representing 128.>>
aByte = CByte(aByte Xor 128)
'Show the value in binary.>>
Display(aByte)
'Set the bit representing 32 back to 1.>>
aByte = CByte(aByte Xor 32)
'Show the value in binary.>>
Display(aByte)
End Sub
Private Sub Display(ByVal aByte As Byte)
MessageBox.Show(Convert.ToString(aByte, 2).PadLeft(8, "0"c))
End Sub
End Class