|
Is there anything I can cast a boolean array to in Java? It would be nice if I could say
boolean[] bools = new boolean[8]; int j = (int)bools;
But I'm not sure if that's feasible in Java.
Started by sil3ntmac on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Static int intFromBooleanArray(boolean[] array) { return new BigInteger(Arrays.toString(array can do this:
int j = bools.length;
No, you can't do this with a boolean[] - but it sounds like you might want a BitSet which is....
|
|
When I try to make a very large boolean array using Java, such as:
boolean[] isPrime1 = new boolean[600851475144];
I get a possible loss of precision error?
Is it too big?
Answer Snippets (Read the full thread at stackoverflow):
You can use an array of longs, encapsulated in a class....
No way.
Not gonna work.
That would be about 70GB worth of booleans.
One...
An array index is an int, not a long, so your "array" is too big to fit into an array.
|
|
Let me illustrate this question with an example:
import numpy matrix = numpy.identity(5, dtype=bool) #Using identity as a convenient way to create an array with the invariant that there will only be one True value per row, the solution should apply to...
Started by saffsd on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Here is another ugly way of doing it:
n.apply_along_axis(base.__getitem__, 0, matrix).reshape((5,1))
If I understand your question correctly you can simply use matrix multiplication:
result = numpy.dot(matrix, base)
If the result must have the same shape... .
|
Ask your Facebook Friends
|
I need to utilize an array of booleans in objective-c. I've got it mostly set up, but the compiler throws a warning at the following statement:
[updated_users replaceObjectAtIndex:index withObject:YES];
This is, I'm sure, because YES is simply not an ...
Started by Allyn on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
NumberWithBool:YES]];
or use a C-array, depending on your needs:
BOOL array[100]; array[31] = YES;
Assuming your array contains valid objects (and is not a c-style array):
#define kNSTrue ((id.
|
|
If I have a 2d array like:
boolean[][] map = new boolean[50][50];
How can I set the outer edge of booleans to true only in a loop?
So, for the following array:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
You would have:
1 1 1 1 1 1 1 0...
Started by Scorcher84 on
, 7 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Integer max = 50; boolean[][] map = new boolean[max][max]; for ( integer x=0;x<max;x++) { map of (X-2) 0's [0,0,0,0,0,0,0,....
The question.
Is:
At the top or bottom of the 2d array to the left or right write a 1 , otherwise a 0 .
|
|
I am working on a code which requires me to store 60*4 boolean values, the titles for these values are being stored in a plist. i require to manipulate the boolean values runtime and couldnt find a way to update the plist file easily..also using sqlite...
Started by Snehal on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
The boolean array, but you could also just let cocoa do it naturally:
NSArray* arrayOfBoolsHave a look at this SO question Possible to save an integer array using NSUserDefaults on iPhone in the worst possible way and take 1k per....
|
|
1) On a 32-bit CPU is it faster to acccess an array of 32 boolean values or to access the 32 bits within one word? (Assume we want to check the value of the Nth element and can use either a bit-mask (Nth bit is set) or the integer N as an array index....
Started by Tom A on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
For question #1: Yes, on most 32-bit platforms, an array of boolean values should be faster, because you will just be loading each 32-bit-aligned value in the array and testing it against....
That, write some tests and get back to us.
|
|
I get obsessed with the best names for arrays and variables that I use, I'll look up words in the thesaurus, dictionary, etc..
So I'm trying to name this array / structure:
$nameMe = array( '392' => TRUE, '234' => TRUE, '754' => TRUE, '464' =...
Started by SeanDowney on
, 10 posts
by 10 people.
Answer Snippets (Read the full thread at stackoverflow):
I would drop "Array" from variable names.
So simply;
Red as they describe what the variable is doing, rather than how it's declared or defined .
To a noun or not, the boolean nature of the array is apparent even without isset().
|
|
I have a ~100 digit string which represents a number in base 10 that I want to convert to either a string representing the number in base 2, or a bool array which represents the number's digits in binary. I can do it easily in Java using BigInteger, but...
Started by theycallhimtom on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Anyway, to give you at least some....
Unfortunately there is no standard C++ class/function to do that .
Either that, or you can use GMP to help you along.. .
That's a hell a lot of digits in binary, and you're going to have some fun time handling it .
|
|
I want to create a set of values in Ruby which I can store and retrieve in a MySQL databse under Rails.
In Delphi I would use:
//Create an enumeration with four possible values type TColour = (clRed, clBue, clBlack, clWhite); //Create a set which can ...
Started by Mike Sutton on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
ColorsSet.include?(color) ? color | sum : sum } end # Get an array of elements forming a mix def.
|