[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Well?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 60
Thread images: 10

Well?
>>
13 ?
>>
>>55697680
is > a g.t. or some bitshit operator?
>>
>>55697737
The bitshift operator is >> in the languages I know. So a single > means greater than.
>>
File: ss (2016-07-22 at 01.13.56).png (8KB, 317x164px) Image search: [Google]
ss (2016-07-22 at 01.13.56).png
8KB, 317x164px
Expected 13 and it is
>>
>>55697680
>>
12 + TRUE isn't valid.
>>
>>55697795
Doesn't even give me a warning in >>55697778
>>
>>55697680
>>55697795

true is 1, so it is valid, its 13
>>
>>55697680
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
>>
>>55697801
That is because C is a high level language and converts a boolean to an integer on the fly without even sending a warning.
>>
>>55697823
Actually no, C is a low level language and doesn't have real bool type. It depends on how the CPU does it.
>>
>>55697804
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 /g/
>>
>>55697837
>needing a bool type
>not just using ints for your boolean logic

step it up son
>>
>>55697837
C knows no concept of boolean type, Pajeet.
>>
>>55697680
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.
>>55697778
And I'm guessing this is C and it returns 13 as well, so thats interesting that both languages do this.

>>55697819
What? It's obviously code, not an equation, as you can tell from the "x +=" line
>>
>>55697931
#include <stdbool.h>
>>
>>55697819
>his language doesn't let him have variables

How can one be so cucked by their own language
>>
>>55697819

Wow, a programming illiterate on /g/! What a surprise!
>>
>>55697804
Isn't true only defined as not zero?
>>
>>55697912
>1 int needs 32 bit
>1 boolean needs 1 bit

Enjoy wasting memory
>>
>>55697804
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.
>>
>>55698008
I have 16GiB of ram power
who cares about 32bits
>>
>>55698008
>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
>>
>>55698007
>Isn't true only defined as not zero?
> isn't true -> not zero ?

The implication order is wrong. You want
true <- not zero
ie not zero is defined as true

where as if you want what true points to thats
true -> 1
true is defined as one

One way implications are confusing the first time you encounter it
>>
>>55698008
>what is memory alignment
moron
>>
https://en.wikipedia.org/wiki/Boolean_data_type
>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.
>>
>>55697823
nice bantz
>>
File: 2016-07-22-144514_590x152_scrot.png (15KB, 590x152px) Image search: [Google]
2016-07-22-144514_590x152_scrot.png
15KB, 590x152px
>>55697948
>>
>>55698096
>>>>>>>>>>>>>>>list
>>
>>55698096
lol dumbass
>>
>>55698096
>thinks the parentheses in OP's pic are square
>>
>>55698055
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.
>>
>>55698096

why not {3>1} or even 43>14 or maybe $3>1$
>>
Error - X has not been initialised
>>
@55698096
7.8/10
>>
File: 1467921032184.jpg (11KB, 250x277px) Image search: [Google]
1467921032184.jpg
11KB, 250x277px
ok guys listen

ok

what if

are you listening guys

what if we add an int and a bolean

crazy huh
>>
>>55697954
>#define true 1

Truly game changing piece of code.
>>
>>55698141
>>55698164
yes
>>
>>55697680
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.
>>
>>55697983
>imperative languages are the only languages
>>
>>55698180
Any good language ought to return 13
>>
>>55698198
I disagree. A language that is very strict about types might not like adding a boolean to a number and error out.
>>
>>55697837

>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.

>>55698198

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.
>>
>>55698193

If you're looking for functional languages, here's a translation:

(define x 3)
(set! x (* x 4))
(set! x (+ x (> 3 1)))
>>
>>55698404
I was thinking about logic languages and having the three lines in OP be constraints on x
>>
File: 45443820.jpg (88KB, 400x400px) Image search: [Google]
45443820.jpg
88KB, 400x400px
>>55698198
>Duck typing
>Good
>>
>>55698404
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)))
>>
>>55698158
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
>>
>>55698868
yes, but only VB is idiotic enough to have true be -1
>>
File: works on my machine.png (17KB, 991x450px) Image search: [Google]
works on my machine.png
17KB, 991x450px
>>55698900
???
>>
File: 1468004838140.jpg (30KB, 436x336px) Image search: [Google]
1468004838140.jpg
30KB, 436x336px
>>55698404
>lisp
>that code
>functional

Anon...
>>
>>55697680
4chin won't lie
>>
>>55697680
x = 3
x *= 4 == 12
x += (3 > 1) == x += 1 == 13
3 > 1 evaluates to true and thus one
>>
>>55697680
You haven't specified the language, so the output is pretty much undefined.
Thread posts: 60
Thread images: 10


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.