Questions tagged [boolean]

A Boolean data type is a data type with only two possible values: true or false.

The Boolean data type represents the simple True or False values of Boolean algebra.

Though one bit is all that is necessary to store a boolean (the 1 = true, 0 = false), it is often advantageous (if unintuitively so) to use larger amounts of memory.

Some programming languages actually define a three-valued logic within their Boolean type.

In , the Boolean class is java.lang.Boolean, the object version of primitive type boolean, and questions may be related to either. Note that the java.lang.Boolean fields may hold null as well, as it's an Object.

11685 questions
4
votes
1 answer

Analyzing a 1-mutable-register instruction set?

Summary of problem I need to be able to generate instructions for a conceptual CPU + instruction set. I have an almost-working algorithm. The CPU only has 1 mutable register (named mut) which always begins as 1, and some amount of immutable…
DanRedux
  • 9,119
  • 6
  • 23
  • 41
4
votes
4 answers

Comma Operator PHP

Both these statements are true: $_POST['foo'] = $_POST['bar'] = 'some string'; //1. with '&&' operator if(isset($_POST['foo']) && isset($_POST['bar'])) { echo true; } //2. with a comma if(isset($_POST['foo'], $_POST['bar'])) { echo…
Edward
  • 1,806
  • 5
  • 26
  • 36
4
votes
3 answers

Store an array within a 2d array Java

So why doesn't this work? Not really sure why this isn't possible- I just want to store an array of size 2 inside a 2d array. I know this would be equivalent to setting storage[0][0] = array[0] and storage[0][1] = array[1], but just wondering why…
Fraser Price
  • 899
  • 6
  • 15
  • 36
4
votes
3 answers

Improve performance of custom aggregate function in PostgreSQL

I have custom aggregate sum function which accepts boolean data type: create or replace function badd (bigint, boolean) returns bigint as $body$ select $1 + case when $2 then 1 else 0 end; $body$ language sql; create aggregate sum(boolean) ( …
Tomas Greif
  • 21,685
  • 23
  • 106
  • 155
4
votes
2 answers

Passing a true value to a boolean

I am trying to learn C# and I am up to an example that uses a boolean. For the life of me I cant figure out why the program isnt noticing that I am trying to pass a value of true to the boolean. Here is the code in the Form.cs: namespace…
user2405778
  • 467
  • 6
  • 16
  • 29
4
votes
1 answer

Boolean and Integer are strings after serialization

I'm using WordPress update_post_meta to save an array like $obj = array( 'array' => array(1, 'zwei', !!3), 'string' => 'abc', 'bool' => true, 'bool2' => false, 'integer' => 1, 'integer2' => 17 ); update_post_meta($post_ID,…
Xaver
  • 11,144
  • 13
  • 56
  • 91
4
votes
5 answers

What do boolean operations on lists mean?

I was going through the source of pyftpdlib and I found this: if self.rejected_users and self.allowed_users: raise AuthorizerError("rejected_users and allowed_users options are mutually exclusive") rejected_users and allowed_users are…
sayantankhan
  • 2,161
  • 2
  • 17
  • 18
4
votes
4 answers

Erlang compound boolean expression

I read the documentation about using and, or operators, but why is the following not evaluating? X = 15, Y = 20, X==15 and Y==20. I am expecting for a "true" in the terminal, but I get a "syntax error before ==".
jeffreyveon
  • 13,400
  • 18
  • 79
  • 129
4
votes
2 answers

What is the boolean interpolation character for string.format function in lua

I'm looking for a boolean interpolation character for string.format(as the title says). I want something that will work this way: print(string.format("nil == false: %b",(nil==false)) %b is just a placeholder, you'll get an error with that. I'm…
Plakhoy
  • 1,846
  • 1
  • 18
  • 30
4
votes
2 answers

Change TRUE and FALSE to Yes and No

I have the following R script: x <- c('PE', 'MG', 'SP', 'GO', 'ES', 'PB', 'DF') y <- c('PB', 'MG', 'SP', 'GO', 'ES', 'SE', 'DF') z <- x == y So that > z [1] FALSE TRUE TRUE TRUE TRUE FALSE TRUE However, I want z (and other logical variables…
Waldir Leoncio
  • 10,853
  • 19
  • 77
  • 107
4
votes
2 answers

How to check the value of a boolean (set by user) with a variable string?

The user sets a boolean to true or false. That does (exemple) ElementNameone = true ElementNametwo = false ElementNamethree = true Etc. Now I have a string that is loaded from a file. The string called name can have values that are Nameone,…
arj
  • 141
  • 1
  • 8
4
votes
2 answers

Find Length of Paths Through Boolean Matrix in MatLab

I have a set of 5x5 boolean matrices, one for example is below: 0 1 0 1 1 1 1 1 0 0 1 0 0 1 1 1 1 1 1 0 0 0 0 0 1 And I would like a way to output, for every connected series of 1's (connected meaning a 1 is to the left, right, above or below…
Jack
  • 209
  • 1
  • 7
4
votes
3 answers

How to avoid that C-header overwrites native C++ type

First I have to explain my ... Situation I have this microcontroller code (plain old C) which includes bool.h with the following content since stdbool.h is apparently not available, especially not with Visual Studio 2008, which is my current IDE…
Michi
  • 681
  • 1
  • 7
  • 25
4
votes
3 answers

Can I always use 1-bit booleans?

In my opinion, one bit is all you ever need for a binary variable like bool. Is it in any way a bad decision to explicitly tell all bools to use only 1 bit? struct Banana { // little fields bool on_off : 1; bool yes_no : 1; bool…
Oleksiy
  • 37,477
  • 22
  • 74
  • 122
4
votes
1 answer

Why do many WPF-classes store boolean values as enum-flags?

If you reflect over the WPF System.Windows.Controls.Control class you can see: public class Control : FrameworkElement { internal ControlBoolFlags _controlBoolField; // [...] internal bool ReadControlFlag(ControlBoolFlags reqFlag); …
HerpDerpington
  • 3,751
  • 4
  • 27
  • 43
1 2 3
99
100