473,686 Members | 3,199 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

largest array possible

i have created a 7-dimensional array [11,11,11,11,11, 11,11] which has 19.5
million elements.

when i try to create 8-dimensional array i get out of bounds system
exception. does anyone know if this limitation is due to amount of memory
in my pc or a limiation of c# language?

thanks
Nov 15 '05 #1
9 2271
> when i try to create 8-dimensional array i get out of bounds system
exception. does anyone know if this limitation is due to amount of memory
in my pc or a limiation of c# language?


write it to a file...
--
H.Schampheleer
hu****@haps.be
www.haps.be
Nov 15 '05 #2
Hi tony,

I don't think that .net has such limitations.
I would say that it is a memory issue.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"tony collier" <me*****@hotmai l.com> wrote in message
news:Xn******** *************** **@194.117.133. 134...
i have created a 7-dimensional array [11,11,11,11,11, 11,11] which has 19.5
million elements.

when i try to create 8-dimensional array i get out of bounds system
exception. does anyone know if this limitation is due to amount of memory
in my pc or a limiation of c# language?

thanks

Nov 15 '05 #3
Actually, I would guess there is a limit because of the limitation of
the Length propery. In the 1.0 version of the framework, the Length
property was a 32 bit integer, and because of that, you were limited to two
billion or so elements.

With the 1.1 version of the framework, you have the LongLength property,
which exposes the length in a 64 bit integer, which means you have an upper
limit of 9,223,372,036,8 54,775,808 elements (needless to say, a lot).

However, what you are running into, like Miha said, is probably because
of a memory constraint. To the original poster, do you really need to have
that many elements in the array? What are you trying to do? Depending on
the type of your elements, the memory alone for such an array could be
restrictive in terms of performance.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Miha Markic" <miha at rthand com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi tony,

I don't think that .net has such limitations.
I would say that it is a memory issue.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"tony collier" <me*****@hotmai l.com> wrote in message
news:Xn******** *************** **@194.117.133. 134...
i have created a 7-dimensional array [11,11,11,11,11, 11,11] which has 19.5 million elements.

when i try to create 8-dimensional array i get out of bounds system
exception. does anyone know if this limitation is due to amount of memory in my pc or a limiation of c# language?

thanks


Nov 15 '05 #4
Sure, but it returns "Length" cast to a long, so the max. value is still 2
Billion elements.

Willy.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:et******** ******@tk2msftn gp13.phx.gbl...
Actually, I would guess there is a limit because of the limitation of
the Length propery. In the 1.0 version of the framework, the Length
property was a 32 bit integer, and because of that, you were limited to two billion or so elements.

With the 1.1 version of the framework, you have the LongLength property, which exposes the length in a 64 bit integer, which means you have an upper limit of 9,223,372,036,8 54,775,808 elements (needless to say, a lot).

However, what you are running into, like Miha said, is probably because of a memory constraint. To the original poster, do you really need to have that many elements in the array? What are you trying to do? Depending on
the type of your elements, the memory alone for such an array could be
restrictive in terms of performance.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Miha Markic" <miha at rthand com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi tony,

I don't think that .net has such limitations.
I would say that it is a memory issue.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"tony collier" <me*****@hotmai l.com> wrote in message
news:Xn******** *************** **@194.117.133. 134...
i have created a 7-dimensional array [11,11,11,11,11, 11,11] which has 19.5 million elements.

when i try to create 8-dimensional array i get out of bounds system
exception. does anyone know if this limitation is due to amount of memory in my pc or a limiation of c# language?

thanks



Nov 15 '05 #5

"Willy Denoyette [MVP]" <wi************ *@pandora.be> wrote in message
news:OU******** ******@TK2MSFTN GP11.phx.gbl...
Sure, but it returns "Length" cast to a long, so the max. value is still 2
Billion elements.


Yes, I am waiting for 128bit procesor so that I can put enough memory into
my computer ;-)

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
Nov 15 '05 #6
I have created 9 dimensional arrays similar to that without any problems. (I
used very dynamic jagged arrays.) I use this in a production environment and
it is absolutely reliable. It does take a good bit of memory, but the code
executes really fast and works really well. So I say, "Go for it!" if you
really need this. If your dimensions are all hard coded, as they appear to
be, you can probably find a better alternative, however.

This looks like a situation where some good data structures-type design work
could really pay off. If you care to share more details, I'll provide more
comments.

If you do move forward with the 7 dimen array, and if you are using it in
code you plan to keep, put a lot of thought into making it OO and
maintainable. If the array is as dynamic as ours, someone coming along after
you won't be able to figure the code out unless it is very nicely designed.
I wouldn't manipulate a 7 dimensional array directly in other code -- put it
behind properties or methods.

BTW, you can have 2 billion elements in each dimension.

"tony collier" <me*****@hotmai l.com> wrote in message
news:Xn******** *************** **@194.117.133. 134...
i have created a 7-dimensional array [11,11,11,11,11, 11,11] which has 19.5
million elements.

when i try to create 8-dimensional array i get out of bounds system
exception. does anyone know if this limitation is due to amount of memory
in my pc or a limiation of c# language?

thanks

Nov 15 '05 #7
ok . thanks everyone for your advice so far. sorry to post several times
the same message - i am getting used to my newsreader software.

This is what i am trying to
do and there is probably a much better way which this newbie hasn't read
or thought about yet.

i am getting prices from x number of suppliers who all quote me a
different individual price for each of y items. no one supplier is always
cheaper than the others.

no. of suppliers: x (preferably unlimited)

no. of items: y (again, preferably unlimited)

i then calculate all the different combination of items from mixed
suppliers. The formula to work out number of combinations =

no.of supplier ^ (to the power of) no. of items.

this requires creating an array of y dimensions with x elements per
dimension to store all combinations

as you will now understand , i have so far only been able to go up to x=
11, and y=7 before running into memory constraints.

items must be able to be added/deleted like in a cart until user
checksout, so no running calculation can take place to try and crunch
numbers as i go. this is why i can't see how array can be made any
smaller.

hope this all makes sense. any ideas to do this in a better way would be
greatly appreciated.
Incidentally, is there any way to initalize all elements in the array to
zero in one fell swoop rather than looping through them? Someone has
mentioned .system.array.c lear - does this work on uninitialized elements?
someone else said that this was a feature not carried over from c++.

Also, someone asked about some suppliers not having all items. So far i
have covered this with another y=7,x=11 array where elements get flagged
for any corresponding combination element that is zero.

A database was mentioned although i know very very little about ado.net
and sql so this would be a real chore for me to do it this way - surely
reading and writing would be too slow for so many entries anyway?

regards TC.
Nov 15 '05 #8
tony collier wrote:
A database was mentioned although i know very very little about
ado.net and sql so this would be a real chore for me to do it this
way - surely reading and writing would be too slow for so many
entries anyway?


There's two ways to solve a problem: the fast way and the right way. If
you want to code an application that will not require any code
maintenance when the number of suppliers and/or items change, ADO.NET is
the way to go.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
Nov 15 '05 #9
the suppliers will be fixed but the items will change on EVERY query as
they are searched for and then selected from an enormous list (which i
don't have access to) by clients thru a webform and and i can't get the
price for the items until i know what the client wants. I then
automatically go to the suppliers for prices and return the bestprice
combination to the user. For this reason i can't pre-populate a database.
I guess I could start with an empty database that populates with a client
request and then deletes entries once client closes session rather than
letting database grow and grow unneccesarily. Does this sound like a
better way than working with arrays?
Nov 15 '05 #10

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

Similar topics

7
7030
by: Nicholas | last post by:
How can I get the largest possible value of the Integer Constants and use it in the program for these types: 1. int 2. long 3. unsigned short Thanks
13
5141
by: Peter Ammon | last post by:
I have a floating point number. I'd like to get the nearest floating point number that is larger or smaller than the given number. I investigated FLT_EPSILON but it only seems to be useful if the given number is 1. Any suggestions? Thanks, -Peter
20
5086
by: Rajesh | last post by:
Hello Everybody, Can anybody help me to write a C program for finding the second largest element in an array. without using any sort algo. The array may conatin duplicate elements. The algo should run in O(n) time. Rajesh
19
8578
by: ramu | last post by:
Hi, I have, suppose 1000 numbers, in a file. I have to find out 5 largest numbers among them without sorting. Can you please give me an efficient idea to do this? My idea is to put those numbers into a binary tree and to find the largest numbers. How else can we do it? Regards
3
3948
by: HEMH6 | last post by:
Who can help solve this problem??? Finding the Largest Value (a) write a function, largest(), that returns the largest value in a signed integer array. The array and its size are passed as arguments. (b)Write a main program that inputs MAX values from the keyboard into a signed integer array, array, and points, using largest(), the largest value to the screen.
9
3056
by: tom | last post by:
Hi! How can I determine the smallest and largest values of numeric types (for example int) possible in my system? I think there exists a function for this task but I don't know it.
38
2438
by: bele_harshad2006 | last post by:
how can i pick up largest no from 5 rows by 5 column matrix????
5
2823
by: akselo | last post by:
Hello folks, I have a function where I pass numbers from a table, and I want to compare them and return the largest horizontal value. I store them in an array, and try the DMAX function on it, but get stuck there. Function landuse(dblmips As Double, dblcie As Double, dblmed As Double, _ dblpdr As Double, dblret As Double, dblvis As Double) Dim varsqft(5) As Double Dim varlargest As Double
8
3922
by: MLH | last post by:
Is there any built-in FN for returning largest value in a group of say 2 - 10 values? Lets say I want a FN something like MaxVal(5, 7, 9, 3, 12) or perhaps MaxVal(79,34). I would wanna see return value of 12 and 79 respectively. What's simplest way to do that in A97?
0
8581
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
8932
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
8778
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...
1
6439
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5795
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2944
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
2
2205
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1933
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.