Well?
Well?
Other urls found in this thread:
en.wikipedia.org
twitter.com
13 ?
is > a g.t. or some bitshit operator?
The bitshift operator is >> in the languages I know. So a single > means greater than.
Expected 13 and it is
...
12 + TRUE isn't valid.
Doesn't even give me a warning in
true is 1, so it is valid, its 13
How to detect a C faggot in one post. The only correct answer is compilation error: cannon cast bool to int.
>x=3
>x=x*4
>thus x=0=3
That's impossible you fucking retard
That is because C is a high level language and converts a boolean to an integer on the fly without even sending a warning.
Actually no, C is a low level language and doesn't have real bool type. It depends on how the CPU does it.
only if your booleans are treated as int ( enumerated type to 0/1)
weakly typed languages are built for fucking retards
Another of these threads showing the retardness of Sup Forums
>needing a bool type
>not just using ints for your boolean logic
step it up son
C knows no concept of boolean type, Pajeet.
I actually expected it to give some sort of type error, but I tried it out in python3 and (12 + (2>1)) actually returns 13.
And I'm guessing this is C and it returns 13 as well, so thats interesting that both languages do this.
What? It's obviously code, not an equation, as you can tell from the "x +=" line
#include
>his language doesn't let him have variables
How can one be so cucked by their own language
Wow, a programming illiterate on Sup Forums! What a surprise!
Isn't true only defined as not zero?
>1 int needs 32 bit
>1 boolean needs 1 bit
Enjoy wasting memory
while(2) works too
where is your god now
It's 13, because 3 >> 1 = 1 and True = 1. There are no other possible interpretations.
I have 16GiB of ram power
who cares about 32bits
>he thinks bool data types only use 1 bit in other languages
on gcc 5.4.0 it compiles to
movl $0, -4(%rbp)
movl $3, -4(%rbp)
sall $2, -4(%rbp)
addl $1, -4(%rbp)
even with -O0 it's known at compilation time
>Isn't true only defined as not zero?
> isn't true -> not zero ?
The implication order is wrong. You want
true 1
true is defined as one
One way implications are confusing the first time you encounter it
>what is memory alignment
moron
en.wikipedia.org
>relational expressions like i > j and logical expressions connected by && and || are defined to have value 1 if true and 0 if false, whereas the test parts of if, while, for, etc., treat any non-zero value as true.
So it's 13 or undefined, depending on the language.
nice bantz
...
>>>>>>>>>>>>>>>list
lol dumbass
>thinks the parentheses in OP's pic are square
And if we read data to compare from user?
int x, y, z;
scanf("%d %d", &y, &z);
x = 3;
x = x * 4;
x += (y > z);
printf("%d\n", x);
So
movl $3, -12(%rbp)
sall $2, -12(%rbp)
movl -20(%rbp), %edx
movl -16(%rbp), %eax
cmpl %eax, %edx
setg %al
movzbl %al, %eax
addl %eax, -12(%rbp)
And what does setg do? It sets al with 1 if y > z, 0 otherwise.
Another mystery solved.
why not {3>1} or even 43>14 or maybe $3>1$
Error - X has not been initialised
@55698096
7.8/10
ok guys listen
ok
what if
are you listening guys
what if we add an int and a bolean
crazy huh
>#define true 1
Truly game changing piece of code.
yes
What language? There are several different ways different languages evaluate an expression like (3>1). My favorite is icon which results in the second argument if 3 is greater than 1 and fails otherwise.
>imperative languages are the only languages
Any good language ought to return 13
I disagree. A language that is very strict about types might not like adding a boolean to a number and error out.
>only if your booleans are treated as int
Err... it is not that C is implicitly treating booleans as integers, it's that in C, the type of a boolean expression is int. There is no boolean type at all. _Bool is just an integral type guaranteed to be able to store at least the values 0 and 1. C also doesn't have a builtin string type. It just has pointers to buffers.
C is a language without a lot of types, and it has flexibility because of that. Because the type of a boolean expression is int, you can use an int as a boolean expression, and store multiple booleans in a single value using bitmasking. Because strings are just pointers, you have freedom to make your own rules about how strings are represented in memory. You don't even have to use the standard of null terminating strings if you don't want to, and many language interpreters written in C don't.
Different languages are built for different purposes. C is built for systems programming, so it makes sense for it to work like this. In more higher level languages, type safety might make more practical sense.
If you're looking for functional languages, here's a translation:
(define x 3)
(set! x (* x 4))
(set! x (+ x (> 3 1)))
I was thinking about logic languages and having the three lines in OP be constraints on x
>Duck typing
>Good
That's still imperative. Functional translation:
(define x (+ (* 3 4) (> 3 1)))
If you want to be silly:
(define x (+ (let ((x (let ((x 3)) x)))
(* x 4))
(> 3 1)))
It's you again
Private sub main ()
Dim x as Interger
X = 3
X = x*4
X += 3 > 1
Msgbox (x)
End
Got 11 in vb6
Did the same on vb.net
Got 11
yes, but only VB is idiotic enough to have true be -1
???
>lisp
>that code
>functional
user...
4chin won't lie
x = 3
x *= 4 == 12
x += (3 > 1) == x += 1 == 13
3 > 1 evaluates to true and thus one
You haven't specified the language, so the output is pretty much undefined.