How long can a string be in Objective-C? [duplicate] - objective-c

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What is the maximum length of an NSString object?
I'm trying to decide on a good way to store my tile data on the parse database. What I need is to store 24x24 values, not sure how long those values will be, but let's say I need to store 24x24 bytes (giving me 256 possibilities for each tile). I was thinking of storing them in a big string, is that possible? is there a limit on how big a string should be? or is there a better way to do this in objective c?
Thanks for any advice.

Re: string length, I don't think there's a hard limit on the length of a string. But in terms of storing this type of data, how about a multi-dimensional array? Here's a discussion on the topic.
How to declare a two dimensional array of string type in Objective-C?

The maximum length is determined by the size of NSUInteger (so, billions).
This question has already been asked and answered on stackoverflow here
What is the maximum length of an NSString object?

Related

What is the best way to hold multiple 3D arrays in SQL? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
A program I am working on currently builds multiple differently sized 3D arrays (50x50x200, 30x30x100 for example).
I need to store these arrays in SQL, so I can pull them out again and display the arrays. I have come across this thread where it describes the best way to store a 3D array. I will be using that data structure.
Another thing to mention would be that many of the same sized arrays will be created e.g. 10 50x50x200. My problem is how to go about storing these arrays. I have given this a lot of thought, and I have subsequently come to a few conclusions:
1 table per array indexed with an ID (x,y,z,ID)
1 table per array size e.g. 50x50 table, 30x30 table etc with a 4D array inside (w,x,y,z,ID)
1 enormous table with a 5D array inside (w,x,y,z,size,ID) - size is whether the array is for example 30x30
What would be the best way to go about storing these arrays?
Edit:
All elements within an array will be retrieved at once;
There is no need for updates within these arrays - once they are saved in SQL they will not change;
After the original insertion, similar to updates, the arrays will not change;
The best way depends on how you are going to manipulate them. If you simply need to store the array in SQL and do no manipulation, then you are storing an object.
You can store the entire object as a varbinary or varchar() using a single column. To the database, they would look like a bunch of bits, which is fine for storing and retrieving.
If you were going to do any actions on the array, then you would want a more native solution. That would probably involve two tables, an arrays table to define each array and an arrayElements table with one row per element in the array, so five columns:
Array id.
x, y, z coordinates.
element value.

Is there a Objective-C or C math function to constrain a variable between a Min and a Max? [duplicate]

This question already has answers here:
Fastest way to clamp a real (fixed/floating point) value?
(14 answers)
Closed 6 years ago.
What I am looking for is a math function that constrains a primitive variable between a minimum and a maximum value in only one single function call, if it exists, in the standard math libraries for Objective-C.
I currently use:
float constrainedValue = fminf( maxValue, fmaxf( minValue, inValue ) );
Since I know that both fminf and fmaxf could potentially have instruction jumps or branches, it seems likely there could be a simple routine that could conjoin both of these operations into one, optimized function.
This topic is thoroughly discussed here: Fastest way to clamp a real (fixed/floating point) value?
'clamp' is the keyword I was looking for.

Storing and computing with real numbers up to an arbitrary precision in vb.net [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
.NET Framework Library for arbitrary digit precision
How can I store a real number, eg, root 2 or one third, up to an arbitrary precision (the precision I need is infinate precision) in vb.net?
I would like to be able to store real numbers and perform operations on them (ie root 2 times root 2) without losing any accuracy - IE storing 1/3 would return the value 1/3 if I needed to retrieve this value.
I was thinking of using a fractal encoding but I am unsure as to the best way to do this.
Storage capacity is not an issue, I just need the real numbers to be 100% accurate.
Will that be a single real number there or does it need to be an arbitrary number of (almost) arbitrary figures? (Sorry for "answer" - for some reason i can't add comments now...)

Data Types Obj-C [duplicate]

This question already has an answer here:
Closed 11 years ago.
Exact Duplicate:
Issue with float and double data types in objective C
[Ironically, to find the duplicate questions you need to know the answer.]
What Every Computer Scientist Should Know About Floating-Point Arithmetic
If it cannot be expressed in base 2, it will not be precise. See also floating point inaccuracy.
0.1 is a 'repeating decimal' in binary (0.0001100110011...) so the representation of 0.1 is inexact. NSLog is likely rounding or truncating the output.

How many objects can an nsarray hold? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Maximum amount of objects in NSArray
I was just wondering how many objects I can put into an NSArray, because I need to find something that functions like an array, but I need to hold a lot of data (between 900 and 1200 strings). I was thinking about using an NSDictionary to hold the data, but it doesn't seem to fit the bill. Do you think an NSArray will hold that many objects, or should I use an NSDictionary?
Technically, NSArray can hold up to NSUIntegerMax objects (this is the largest value that can be returned from count). On a 32-bit system like the iPhone, that is a little over 4 billion. On a 64-bit system like most Macs, it is many orders of magnitude higher. By the time you even need to think about running out of room in an NSArray, you're going to have other scaling problems to deal with first, like the fact that 4 billion four-character strings will take up something like 16 GB of memory.
NSArray has two internal implementations for differently sized arrays — 1200 items would still be well within the "small array" implementation.
How much memory do you have?
There is no practical upper limit other than the number of bits it takes to hold all that data. 1200 items is fine. But if those items are each 10 thousand word strings, you may start needing too much memory to hold them all.
You can store an unlimited number of objects in an NSArray until you run out of memory. 900-1200 strings is not a large number, but it obviously depends on the length of each string. Do you know in advance whether they will be long?