[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]

/dpt/ - Daily Programming Thread

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: 413
Thread images: 20

File: daily programming thread2.webm (2MB, 600x338px) Image search: [Google]
daily programming thread2.webm
2MB, 600x338px
old thread: >>52939611

what are you working on, /g/?
>>
First for Go.
>>
Reminder that Python is not a good language
>>
What's the best text editor and why is it GNU nano?
>>
Common Lisp is not the best language, but it's the best dynamically typed language.
>>
>>52942409
How can I make a data structure with a type parameter in Go?
>>
>>52942393
I'm not working on anything, I just waste my time watching animu.
>>
>>52942431
Reflection
>>
>>52942411
Reminder to check for autism as early as possible.
>>
>>52942441
>half of /g/ in a nutshell
>>
Someone with a Twitter tell based Milo about that triggering BBC headline.
>>
>>52942411
Reminder that the obvious is obvious.
>>
>>52942431
>>52942442
go (de)generate
>>
>>52942442
u avin a giggle m8?
>>
>>52942393
Learning x86 assembly as my first language

>>52942425
What's so great about nano?
>>
>>52942393
kill yourself
>>
>>52942460
Reminder that Python literally cannot do 2 things at once.
>>
File: kill_yourself.jpg (56KB, 579x567px) Image search: [Google]
kill_yourself.jpg
56KB, 579x567px
>>52942483
>>
>>52942495
it's lightweight, easy to use and is just useful enough without going full autismo and spending weeks "learning your editor".
>>
File: emacs@arch_061.png (373KB, 2556x1039px) Image search: [Google]
emacs@arch_061.png
373KB, 2556x1039px
>he doesn't compile to PDF
How does it feel to be a shitgrammer, /dpt/?
>>
>>52942495
>What's so great about nano?
People who are too lazy to learn vim can feel smug because at least they're not using notepad.

>>52942526
You can be as productive in vim after 5 minutes of learning it as you can in any other editor. After 30 minutes, you'll be doing even better.
>>
>>52942495
Serious? That's a poor choice. x86 assembly code is hardly portable.
>>
http://www.bbc.co.uk/news/technology-35559439

How can men even compete?
>>
>>52942541
>third time
>>
>>52942495
>What's so great about nano?
It's more usable than Vim without being as bloated as Emacs.
>>
File: strong woman in the military.webm (2MB, 613x360px) Image search: [Google]
strong woman in the military.webm
2MB, 613x360px
>>52942541
>>
>>52942540
Well what architecture do you recommend then? I have processor that uses x86 and figured i learn that
>>
>>52942539
how the fuck is vim any more useful than nano?
Do you type on one of those topre HHKBs and only use vim because your keyboard has no arrow or navigation keys?
>>
>>52942565
vim is the most usable editor m8

but nice b8
>>
>>52942571
Hope that gun's not loaded. She's pointing it all over the place.
>>
>>52942580
Time spent reaching to the mouse or arrow keys for navigation is time wasted, friend.
>>
>>52942575
I'm saying it's a poor choice for your first language.
>>
Rate my feminist int averaging function
int average(int feminine, int masculine)
{
return feminine; // all numbers are equal
}
>>
>>52942571
kek i like how they aren't helping her up like whiteknight millennials would
>>
>>52942571
obligatory
http://www.dailymail.co.uk/news/article-2512412/Female-RAF-recruits-100-000-compensation--march-like-men.html
>>
>>52942609
I want to know what's going on under the hood before i do a higher level language like C. It's not uncommon even these days to learn assembly as a first language
>>
>>52942541
>women's acceptance rates are 71.8% when they use gender neutral profiles, but drop to 62.5% when their gender is identifiable

Unidentifiable
>This fixes a crash in foo.cc

Identifiable:
>I AM A PROUD INDEPENDENT WOMYN AND YOUR USE OF THE PHRASE "Disable transparency" IS TRANSPHOBIC RAPE CULTURE
>>
>>52942607
>time spent reaching for the mouse
I don't even use arrow keys, I use the nav cluster.
Nano has all the features you could ask for without turning it into a bloated IDE with autocomplete because you're too stupid to learn the libraries you're using.
>>
>>52942571
Patriarchy did this.pdf
>>
>>52942623
kek
>>
>>52942393
What anime is that?
>>
>>52942623
int average(int feminine, int masculine)
{
return feminine; // all numbers are equal expect male especially CIS white male because cis white males are members of the patriarchy as thus the scum of the earth and a such should check their privilege
}

Your code wasn't feminist enough
>>
>>52942628
maybe £100k is too much but i think they do have a case

>According to RAF official policy, female recruits should not be expected to extend the length of their strides beyond 27in. They should also be placed at the front of any mixed squad to dictate the pace. But while undergoing basic training at RAF Halton in Buckinghamshire, the claimants were forced to extend their strides to 30in – the standard stride length for men on parades and marches.
>>
>>52942631
yes it is
>>
>>52942684
>look i ruined the joke
>>
>>52942690
Even if it is uncommon i want to know what the compiler is doing
>>
>>52942691
The joke is women talk too much dum dum
>>
>>52942711
This is a blue board desu senpai
>>
>>52942631
Most computer architecture / operating system classes have introduction to programming (usually a C, C++ or Java class) as a prerequisite.
>>
>>52942429
you're forgetting about Scheme mate
>>
>>52942711
does that pass as legal penor censor in japan? the upperleftmost dick is barely censored at all and the others are just a bit pixelated, not actually hidden
>>
File: Promotion.jpg (17KB, 320x375px) Image search: [Google]
Promotion.jpg
17KB, 320x375px
>>52942711
Thanks to you I'm getting a corner office.
>>
>>52942685
Agreed. It's a retarded requirement that doesn't seem to have anything to do with effective warfare.

It's like not letting people use their dominant eye for aiming.
>>
>>52942713
hate to break it to you but compilers are written mostly in c
or c++ in the case of gaycockcaresser and clang
>>
>>52942751
censorship over there is mostly a formality at this point
the only rule is that you have to censor genitalia if you're selling your artwork for a profit, making it commercial pornography
>>
I'm trying to write a lib for IMDB, but there is literally no documentation.

Any tips for reverse engineering the incredibly vague URL parameters? I can't figure them out for the life of me.
>>
>>52942711
>pretends to not know exactly what anime OP posted by adding "or some shit"
>has gay shit saved on his harddrive

or, how about

>doesn't like that OP posted gay shit
>post gay shit
>>
>>52942734
It's 2016, I have a dynamic IP.

If I get range banned all I have to do is pretend I'm an innocent user caught in it. :^)
>>
>>52942711
PROMOTIONS!

>>52942737
Will learning C first seriously make learning assembly a lot easier?
>>
>>52942784
yes
c is portable assembly that you can actually make useful things in
dont learn c++
>>
>>52942768
Why would you not write a compiler in a language that's easier to formally verify?

baka
>>
>>52942393
Fuck your pedophile anime shit
>>
>>52942797
C++ is portable C that you can actually make useful things in
don't learn C
>>
>>52942812
Most microarchitectures support C and not C++.
>>
>>52942797
anyone who regurgitates the "portable assembler" meme has never used C
The portable assembler meme may have been true in the 80s when all compillers were stupid as hell and every statement represented something 1:1 in ASM.

You know what -O2 does?
It cuts your assembler output by half by doing contrived shit that somehow runs faster than anything you could handwrite yourself.
>>
>>52942799
you'd love python
>>52942812
c is more portable than c++, and i only said that because c is simpler and a better first language
you can go from c to c++, but not really the other way around
>>
>>52942812
>C++
>portable
Practically every platform has a C compiler
Few have a C++ compiler
>>
>>52942821
That's not what microarchiteture means.
>>
>>52942821
que?
>>
>>52942768
>>52942797
Very well, I'll learn some C before tackling assembly
>>
>>52942828
ok, it's more than portable assembler :)
happy?
it's not like you need to use optimizations, i'm sure linux doesn't.
>>
>>52942828
>"portable assembler" meme has never used C
The "portable assembler" meme was created by people who used C for serious things like operating systems, GUIs, and programming languages.
>>
>>52942828
The idea is that you can compile the C code for different architectures. Good luck doing that with x86 assembler
>>
>>52942784
Yes. You learn basics of imperative programming with C. Then assembly language teaches you how it is underneath and you'll have a lot of "ooh" moments when comparing the standard practices and methods for both.
Knowing C will also help you understand what really is happening in the objective-oriented languages (ateast mainstream ones). I think half of their features don't really make sense until you consider the relation of OOP and procedural practices in history of software.
So just study C extensively for now.
>>
File: AHAHAHA.gif (491KB, 500x220px) Image search: [Google]
AHAHAHA.gif
491KB, 500x220px
>>52942861
>>serious things
>GUIs
>operating systems
>programming languages
>>
File: 1431533518890.jpg (129KB, 710x878px) Image search: [Google]
1431533518890.jpg
129KB, 710x878px
>C
>C++
>Portable
The fuck are you guys talking about?
>>
>>52942933

(void) 0
// 100% portable C program
>>
>>52942973
;
>>
>>52942933
If you want to maximize the amount of platforms your program can run on, writing it in C or C++ are the best choice.
>>
>>52942933
C preprocessor makes your programs 100% portable on every platform you intend to support
>>
>>52942973
Wrong.
(void) 0;
/* 100% portable C program */
>>
>>52942393
Not sure if this is the right place for this.

My dad wants me to create a html file that he can host on his server to control his lights and sprinklers.

What can i use to compile, Im looking for something simple.

Just an empty place to put the code, and a display so i can see what happens every time i run it.

Im fully aware that im a fucking chump , this should be so simple but im drawing a blank at finding a simple fucking compiler.

>Put the spoon in my mouth, just this once please.
>>
>>52942995
No it doesn't, the amount of platform specific code explodes exponentially for every platform that isn't GNU/Linux compatible.

Your definition of portable is extremely uncharacteristic of what experienced programmers consider portable.
>>
>>52943040

GO TO WEBDEV FAGGOT

:)
>>
>>52943040
please be bait please be bait please be bait
>>
>>52943040
Neither HTML, Java nor CSS compile.

They're interpreted, typically by web browsers.
>>
>>52943090
Will do

>>52943131
Dont know what you want me to say. i have no idea what im talking about and i want to learn.

How dare i post here and ask for help.
>>
>>52943172
GOOGLE FIRST FAGGET
>>
>>52943171
*Javascript, not Java.
Java compiles.
Javascript typically does not.
>>
>>52943212
Java half compiles
>>
>>52943171
Thanks, I understand now.

I think i can just use one of the free editors and ftp it to the ilon. I have no idea what i am doing but i will figure it out.

Go back to whatever you guys are working on.
>>
>>52943265
>Java half compiles
It isn't compiled to native machine code, but it is still compiled.
>>
>>52943280
Nothing productive whatsoever
>>
>>52943265
And then needs to be interpreted.
And then compiles some more. Sometimes.
>>
>>52942580
regex, /, go to line, ... and the plugins
>>
What do you think makes women write better code? Please don't just dismiss this question as trolling, there's a BBC article about it. The BBC is a respected news source, right?
>>
>>52942625
then she wouldn't be allowed to pass
>>
>>52943040
define expression « lights & sprinklers » for French Moi.

What you want is a web server - server in a different meaning than « this PC is my dad's server » - that is : a program that presents a webpage to clients, the webpage being constituted of html. Using a specially crafted web server, you can create web services with special functionnality, such as responding to commands formulated à la web (example : translate.google.com), and including dynamic data in web pages (example : ipconfig.me).
So yeah, what you want is a web service for controlling lights and sprinkles. Do you know how the computer can access them?
>>
>>52943073
>No it doesn't,
Yes it does.
> the amount of platform specific code explodes exponentially for every platform that isn't GNU/Linux compatible.
Writing some platform specific parts in C or C++ is way easier than say porting the entire jvm to a new platform.
>Your definition of portable is extremely uncharacteristic of what experienced programmers consider portable.
I'm using the practical definition that programmers actually care about.

If you want a program to run on:
embedded devise with cpus varying from 16-32 bit, with one's or two's complement integers, with or without floating point (and possibly non-iee754), with memory capacity ranges from a few KB up to gigabytes, speeds from megahertz to gigahertz, etc.
If that is your span of devices, C is your only realistic choice if you want anything to run at all.

That makes it the most portable language.
>>
is it feasible to start with C as first sprache? and if so what should I go through to learn it, I found learn C the hard way but it says I should know other shit first.

>>52943381
It may be because that because most just aren't interested in doing it at all, the ones that do get into it are serious nerds.

though that's just my assumption
>>
>>52943354
nano has that too

plugins are the admission that your editor is inferior without the use of shitty hacks bolted on to your editor

>>52943381
They get their code accepted more often because most of their pull requests consist of trivial non-code stuff like adding code of conducts and changing all the pronouns in comments to gender neutral ones.

Plus, most men in tech these days are numales who are more than quick to accept a pull request from a woman if it gives them a reason to talk to one.
>>
>>52943354
Macros are also super useful, you can indent multiple lines at once, you can run bash commands from it, etc, etc...
>>
>>52942539
Nano is a very lightweight and simplistic editor that does its job without any bloat or needing any fancy shmancy features
>>
>>52943439
nano has that too
seriously, just read the built-in help
>>
File: 1429234426637.jpg (50KB, 570x473px) Image search: [Google]
1429234426637.jpg
50KB, 570x473px
>>52943411
Go back to /agdg/, you aren't ready for /dpt/ yet.
>>
File: The-C-PROGRAMMING-Language-C.jpg (37KB, 465x670px) Image search: [Google]
The-C-PROGRAMMING-Language-C.jpg
37KB, 465x670px
>>52943417
>is it feasible to start with C as first sprache?
Yes.

>and if so what should I go through to learn it
Pic related.

Don't let other people talk you out of this book. If you do the end of chapter exercises you'll be fine.
>>
>>52943464
You must have replied to the wrong post.
>>
>>52943432
But the BBC article specifically says "Women write better code."
>>
>>52943457
OK, I didn't know that. Honestly, I use Vim because it's a cli editor that I know how to use well.
I don't care much about editors, they should just make coding easier and more pleasant.
>>
this is true, right?

r-right...?
>>
>>52943547
consider suicide
>>
>>52943505
No, seriously go back.

We don't need your "OGL 2.1 and ANSI C for ULTRA PORTABILITY xDDD" shitposting.
>>
https://www.google.co.uk/search?q=Women+write+better+code&tbm=nws

Are you telling me all these news articles are wrong?
>>
>>52943570
how much time do you waste daily, spreading /pol/tard bullshit? do you come from stormfront?

>>52943457
>>52943432
>nano has that too
>CTRL-something for everything
no thanks.

>plugins are the admission that your editor is inferior without the use of shitty hacks bolted on to your editor
uhm, some plugins practically make vim an IDE, m8
>>
>>52943562
i am
>>
>>52942777
I wish I could help you anon, as I had a similar idea for manga-updates.com but am just as lost as you.
>>
File: dolphin.png (305KB, 674x515px) Image search: [Google]
dolphin.png
305KB, 674x515px
>>52942393
WHERE IS THIS FROM I WANT TO KNOW
>>
>>52943511
But you have no way of knowing the difference between "good code" and "shit code" because you're not a programmer.
>>
>>52943565
It appears it is you who needs to go back to adgd then, they really like Unity, C#, Java and JS 'web apps' there.
>>
Hey, gee, how can I average 2 Integers by reference in Java?
>>
Guys, i have a java question. What is the difference between webview and webkit?
>>
>>52943586
They don't have an API yet no? I just did a cursory Google and all I could find was "we're working on it".

IMDB's is fully functioning, but completely worthless. A search for the actor "Nicholas cage" - http://www.imdb.com/xml/find?json=1&nr=1&nm=on&q=Nicholas+Cage

It returns his ID, now if I wanted to get a list of his films I'd have to somehow magically know how to construct a URL that employs an ID as it's parameter.

Who the fuck writes a JSONP API and then provides literally 0 documentation. Worthless sack of shit.

I've never dropped a project this fast before.

It was finally a chance for me to write a library, but there's simply no point in trying to work with it.
>>
>>52943577
>how much time do you waste daily, spreading /pol/tard bullshit? do you come from stormfront?
Probably the worst thing I've ever been called in my life.

Why do you deny all those articles? There's the Guardian, there's the BBC, and loads more respected news sources.

Women are better coders and that's ok.
>>
>>52943547
No. Read about mutability.
For better understanding of Python and programming in general, I recommend reading Data Structures and Algorithms in Python.
>>
>>52943700
wrong, it was indeed True
>>
>>52943699
stop false flagging you shit
nobody is buying it
>>
File: brain problems.jpg (19KB, 303x296px) Image search: [Google]
brain problems.jpg
19KB, 303x296px
>>52943547
>makes a bunch of lists with only one number from x down to 2
>until it gets to x = 1
>then it gets an infinite loops constantly creating and freeing a new list and adding 1 to a list of all 1s
>>
>>52943692
>They don't have an API yet no
No they don't, they've been "working" on one for years now. Hell they still don't even have an android app, and those that tried to make a 3rd party app all gave up.
I'm not sure if it's a good alternative but If you don't plan on messing with user accounts you might consider using the OMDb API instead.
>>
>>52943732
Call it a false flag all you want, the fact remains, science proves women are better programmers.
>>
>>52943388
so they're actually whiteknighting her by giving her a chance to pass.. hehe just joking
>>
>>52943714
Wow, I see it now. I didn't think it through at all.

>>52943837
OK, nobody really cares about gender here.
>>
>>52942833
>Few have a C++ compiler
bwahahahahahaha, found the csscuck
>>
>>52943811
I thought so, but it's so easy to use I didn't feel like writing a wrapper was necessary.

Decided to port some existing code from some 4chan stuff I've been doing into a wrapper for the Vichan API. Seems like a more worthwhile task.
>>
It wasn't peer reviewed and higher acceptance does not automatically equal "better code", how are all those "credible" news sites getting away with it?
>>
>>52943995
Wanna quote someone?
>>
>78.6 percent of pull requests made by women were accepted versus the 74.6 percent accepted by men

I wonder how many of those women were actually trans "women."
>>
>>52943995
>news sites
>knowing what they're talking about
>>
currently having fun with Postgres 9.5
>>
File: Capture.jpg (25KB, 704x90px) Image search: [Google]
Capture.jpg
25KB, 704x90px
>>52944062
>4% difference
>that sample pool difference
>>
>>52943565
>muh webapps
>muh chrome
fuck off to /wdg/ worthless shitstain
>>
>>52942393
Learning Elixir because I wanted to learn Erlang. Will post FizzBuzz when I learn more.
>>
>>52942537

I compile to pei-x86-64. But maybe that's because I'm trying to make programs, not documents.
>>
>All this damage control
Can't you just accept women are better at some things than men?
>>
>>52944096
Holy fucking shit lol
>>
>>52944119
Are you new, or is your bot just shit?
>>
>>52944132
I'm sorry, but I don't understand your question.
>>
>>52944132
His bot is shit
>>
File: cute anime pic 0585.jpg (38KB, 400x400px) Image search: [Google]
cute anime pic 0585.jpg
38KB, 400x400px
>>52944119
>this is what qualifies for trolling these days.
>>
>>52944119
t. Marcosoft Rubio
>>
File: 1267813268776.jpg (34KB, 294x313px) Image search: [Google]
1267813268776.jpg
34KB, 294x313px
>spend an hour figuring how to build Assimp 3.2, can't get it to work
>find out I already have a working Assimp 3.1.1 while browsing through my lib folder
>completely forgot about that
>mfw
>>
>>52943598
>>52942664

himegoto
>>
>>52944224
>Assimp
I thought you were making fun of GIMP at first.
>>
alright /dpt/, which one of you faggots is this? https://github.com/rein
>>
>>52944357
They are productive. Which one do you think?
>>
Is it true that C lacks the flexibility of safely averaging 2 ints? Why are you using such a limited language instead of Rust?
>>
>>52944357
>reimplementing the haskell library in C++
>>
>>52944419
That meme is becoming old.
>>
>>52944357
>lolisp
>>
>>52943381
(You)
>>
>>52944419
you can easily do it by casting to long long ints
>>
>>52944520
NOT
PORTABLE

WHY CANT YOU UNDERSTAND
>>
>>52944469
>still doesn't know the solution
gtfo pajeet
>>
>>52944520
you can also cast to dubs
>>
>>52944585
loss of precision
>>
>>52944565
my bad, they hold AT LEAST certain values, so long long ints might not be able to hold the sum of two ints. but you can use fixed width types like int32_t and casting to int64_t. or is that not portable either?
>>
>>52944419
What? You divide both numbers by two, add them together and if any of them were odd before you add 1.
>>
>>52944605
average of 2 int"s != average of 2 int32_t"s
>>
>>52944615
doesn't give the correct result for all possible inputs

>>52944619
if you want to go the cast route you could use some arbitrary precision library like gmp
>>
>>52944652
Where does it fail?
>>
>>52944652
>needing an external library

I guess he was right, it can't be done
>>
>>52944603
lol no
>>
>>52944689
it can be done in a simple function without any libraries or anything
>>
>>52944697
Don't feed the trolls. Don't even look at them.
>>
>>52944673
it doesn't; he's just a moron
>>
>>52944693
Are you the same faggot from earlier?

You realise an int can be the same size as a long double?
>>
>>52944673
>>52944721
k tard

int avg(int a, int b)
{
return a / 2 + b / 2 + (a % 2 != 0 || b % 2 != 0);
}


>avg(-1, 1)
>1
>>
>>52944565
bwahahahaha, this retard actually believes this!
find me an architecture where (int) (((long long) a + b)/2) doesn't give the correct average
protip: you can't
>>
I see where you guys have been going wrong!
You've been returning integers!

The average of two integers is not an integer
>>
>>52944721
I'm thinking it fails for negative numbers, but that's left as an exercise to the reader. Also I assume 2s complement, but I would kill myself if my computer wasn't 2's complement.
>>
>>52944756
>average of two integers is not an integer
jscuck detected
>>
>>52944741
>>52944757
Yeah, what I was thinking.
>>
>>52944756
an int averaging function obviously returns an int. if you wanted a float you'd simply use a float averaging function and if you wanted a double you'd simply use a double averaging function.
>>
>>52944753
>>not portable
>find me an architecture
You don't belong here, friend
>>
>>52944778
>damage control
MAXIMUM!
>>
>>52944757
>>52944773
>avg(0, 1)
>1
>>
>>52944419
Funnily enough, I looked into Rust ... for about 5 minutes. Dropped it as soon as I discovered that they also punted on doing anything meaningful about integer overflow (because implementing exceptions was too much effort and messed up their nice, clean, oversimplified language).

Providing "safe" arithmetic operations as alternatives which are an unmitigated nuisance to use (and which no-one will actually use) while the infix operators are unsafe isn't a solution. Nor are "optional" checks which are only enabled in "debug" builds.

If the overhead of checking individual operations is too much, then do static analysis so that you can omit the checks when they can't occur. But that would require doing actual work.
>>
>>52944753
/thread
>>
>>52944791
>>52944778
You could just write a valid C compiler that breaks that.
>>52944795
It's rounding up.
>>
>>52944357

I dunno, but I like this guy's choice of language for implementing tests

https://github.com/rein/Monado/blob/master/examples/tests
>>
>>52944807
usually (especially in C) you want truncation for integers unless otherwise specified
>>
>>52944807
>a valid C compiler that breaks that
show it to us or gtfo
>>
>>52944791
Go back to r*ddit you backpedalling 12 year old
Alternatively, show me the paragraph of the C standard that says a double must be bigger than an int
>>
>>52944824
Generally, but it was never defined.
>>
>>52944570
int sgn (int a) {
if (a < 0) {
return -1;
} else if (a == 0) {
return 0;
} else {
return 1;
}
}

int avg (int a, int b) {
int s;
s = sgn (a) * sgn (b);
if (s <= 0) {
return (a + b) / 2;
} else {
int d;
d = (a - b) / 2;
if (d < 0) {
return a - d;
} else {
return b + d;
}
}
}


What did you say?
>>
>>52944775
>obviously returns an int
Obviously doesn't
(3 + 4) / 2 = 3.5

Integers aren't closed under division by 2
>>
File: 5 - Extra-Large.png (4MB, 8192x8192px) Image search: [Google]
5 - Extra-Large.png
4MB, 8192x8192px
>>52942393
I get the feeling that I should have moved on to something more complex than Processing after having tinkered around with dungeon-generation algorithms for several years...
>>
>>52944753
Fails on ILP64 architectures (where int is 64-bit). Not common, but they exist.
>>
>>52944841
back to /wdg/, webcuck!
alternatively, show me a C compiler where adding 2 ints overflows a long long
>>
>>52944865
S P E R G
P
E
R
G

https://en.wikipedia.org/wiki/Rounding#Rounding_to_integer
>>
>>52944741
>a % 2 != 0
Where is it stated in C89 spec that it must be 0 or 1? True can be any non zero value, not just 1.
>>
int avg (int a, int b)
{
return (a/2) + (b/2) + ((a%2) && (b%2));
}
>>
>>52944890
incorrect
see >>52944882
>>
>>52944865
not in C
>>
>>52944882
kill yourself.
>>
>>52944869
have you tested it?
>>
>>52944914
I know that it's hard to recognize that we're wrong but you have to. Otherwise you'll never progress anon.
>>
>>52944880
what does this have anything to do with the C standard?

>>52944882
It's easy to find, at least in c99 and c11. I do not have a copy of c89.
>>
>>52944880
>the C standard is for webcucks
>it's ok to fudge standard compliance
>this code will never be compiled on another compiler

Remember when I said you didn't belong here? That you should go back to r*ddit? (that fucking word blocks you from posting)
>>
>>52944419
Averaging an arbitrary number of ints in C is easy:
static inline int sign(int x)
{
return (x > 0) - (x < 0);
}

int average(int n, ...)
{
va_list args;
int avg = 0;
int odd[2] = {0, 0};
int zeros = 0;

va_start(args, n);

for (int i = 0; i < n; ++i) {
int val = va_arg(args, int);

if (val == 0) {
++zeros;
continue;
}

avg += val / n;

if (val % n != 0)
++odd[val < 0];
}

va_end(args);

avg += odd[0] / 2 - odd[1] / 2;

if (n % 2 != 0)
avg += zeros / 2 * sign(avg);

return avg;
}
>>
Wow /dpt/ is shit today, guess I'll be productive now.
>>
>>52944882
>>52944890
I never intended it to be written that way, I think
(a&1)|(b&1)
is better.
>>
>>52944882
(int) bool is 1 if true, 0 or if false. i thought it was in C89? at least in later standards. and just fucking use a ternary or if statement then you FUCKING FAGGOT

also a correct solution is:

int avg1(final int a, final int b)
{
if(a > 0 == b > 0) {
return a / 2 + b / 2 + (a % 2 + b % 2) / 2;
}
return (a + b) / 2;
}
>>
>>52944936
>It's easy to find, at least in c99 and c11.
Show me.
>>
>>52944943
>Wow /dpt/ is shit today
Don't fool yourself, today is no different than any other day.
>>
>>52944909
int avg (int a, int b)
{ return (a/2) + (b/2) + ((a%2) && (b%2)) ? 1 : 0; }

>>52944945
>|
>>
>>52943669
Is it possible to make an android browser that uses webview without using webkit?
>>
>>52944961
the insufferable sperg meme is relatively new
>>
>>52944965
What's wrong with it?
>>
>>52944937
>my other compiler overflows long long when I add 2 ints
off yourself, css fucboi
>>
>>52944881
I know what rounding is.
>>52944912
"write an equality test"
int x = 4;
if (x = 3) ...
>>
>>52944865
(3 + 4) / 2 == 3
>>
>>52944954
>also a correct solution
nope, still wrong
>>
>>52944965
Far better but still incorrect. Just try it please.
>>
>>52944992
I'm sorry, but you're not only too retarded, but also too incompetent to use this thread.

Why not look for a programming thread on /sci/? You'll probably like them.
>>
>>52944882
> Where is it stated in C89 spec that it must be 0 or 1? True can be any non zero value, not just 1.
Incorrect. Any non-zero value is considered true, but operators which return a boolean can only return 0 or 1. E.g. §3.3.8:
Each of the operators < (less than), > (greater than), <= (less
than or equal to), and >= (greater than or equal to) shall yield 1 if
the specified relation is true and 0 if it is false./38/ The result
has type int.
>>
>>52945016
for which input does it fail you idiot?

>inb4 it fails because of the final
>>
>>52945016
You know, to prove something wrong, a counter example suffices, not hearsay.
>>
>>52944994
>if (x = 3)
end yourself, memejs faggot
>>
>>52944942
shit
int
average (size_t n, int num[n])
{
int avg = 0, odd[2] = {0, 0}, zeros = 0;

for (size_t i = 0; i < n; i++)
{
if (num[i] == 0)
{
++zeros;
continue;
}

avg += num[i] / n;

if (num[i] % n != 0)
++odd[num[i] < 0];
}

avg += odd[0] / 2 - odd[1] / 2;

if (n % 2 != 0)
avg += zeros / 2 * sign (avg);

return avg;
}
>>
trying to do a list combination in F#, the catch is the elements in the list must be sorted into groups of 2,3, and 4
>>
>>52945027
i knew it. sperg got rekt
>>
>>52945026
>got told hard
>out of arguments
>better try some damage control

inb4 pretending
>>
Can you claim inactive github usernames senpai?
>>
>>52944954
>final
wat

>>52944955
6.5.9 Equality operators

>Each of the operators yields 1 if the specified relation is true and 0 if it is false.
>>
>>52945037

.. perhaps you should read the context of my post.
>>
>>52944954
> i thought it was in C89?
It is. I suspect that he chose C89 specifically because the drafts are harder to find (and none of them are hosted by an ISO member body, unlike C99).

>>52944955
For C99, see e.g. §6.5.9
       [#3]  The  == (equal to) and != (not equal to) operators are
analogous to the relational operators except for their lower
precedence.79) Each of the operators yields 1 if the
specified relation is true and 0 if it is false. The result
has type int. For any pair of operands, exactly one of the
relations is true.
>>
>>52944861
Why nobody dare to criticize my solution? Is it correct? Does the C89 MASTER RACE win once again?

>>52945027
Interesting. What is your source? And by the way your solution is still incorrect event if true and false resolve to 1 and 0.
>>
>>52945054
>got told
>general manner of speech

Are you legitimately under 18?
>>
>>52942510
What are threads?
>>
>They're people still arguing that that C is portable despite the fact complex C programs often aren't even portable between C compilers
>Even the fucking Linux Kernel doesn't compile on Clang unmodified
>>
>>52945085
>>final
i had it in a java file for easy testing, and the formatter put in final automatically when i formatted the whole file, and then i forgot to remove it from the function
>>
>>52945111
>what is GIL
>>
Wait, I don't get what was wrong with
return a/2 + b/2 + ((a|b)&1);
>>
>>52945106
>MAXIMUM DAMAGE CONTROL
>hey guise, let's talk about something else
back to jerking it to animu, shitlord
>>
>>52945020

That operator precedence is fucking retarded.

#include <stdio.h>
#include <limits.h>

int avg (int a, int b)
{ return (a/2) + (b/2) + (((a%2) && (b%2)) ? 1 : 0); }

int main(void) {

printf("%i\n", avg(INT_MIN, INT_MAX)); // -1
printf("%i\n", avg(INT_MIN, 0)); // -1073741824
printf("%i\n", avg(0, INT_MAX)); // 1073741823

printf("%i\n", avg(-3, 4)); // 1
printf("%i\n", avg(3, 4)); // 3
printf("%i\n", avg(12, 16)); // 14

return 0;
}
>>
>>52945092
>>52945085
Checked. Bools evaluate to 1 and 0. It is stated in the C89 standard.
>>
>>52945124
C is portable as long as you follow the standard and don't invoke implementation defined or undefined behaviour.
>>
>>52945136

I'm asking a question you fucking 12 year old child. Respect your fucking elders you piece of shit cunt.

Are you under 18?
>>
>>52945135
Negative numbers, but you could probably just test for that too.
Also, that's more concise than what I wrote, nice.
>>
>>52945137
Still incorrect. Try with -3 -3. Your function just tell me that the average of -3 -3 is -1.
>>
>>52945124
you can choose to write it portable or you can choose to use compiler-specific extensions because gcc is the only good compiler anyway.
>>
>>52944880

My google-fu on target triplets is failing me, but I believe that for Tru64 Unix, where sizeof(short) == sizeof(int) == sizeof(long) == sizeof(long long) == 8, it should be

alpha-dec-unix-gcc

Which had support discontinued in gcc 4.6, but should still work for the earlier versions.
>>
>>52945158
>pls let me get away, my ass is already bleeding from that rape I received from your big dick
now back to your designated place, apu!
>>
>>52945124
>the linux kernel needs rewriting in C
new meme material fa.ms
>>
Guys, can someone point me to a quick tutorial on TCP connections using C? I found a nice job opening and it requires a program to be made. That program uses TCP connections, and although i never used TCP with C, I'm pretty good on that language, which means that the TCP thing is the only thing stopping me.
>>
>>52945153
C is only portable as long as use ultra-modern libraries designed specifically for portability.

And pray to god you're don't have a version mismatch.
>>
>>52945163
I give up
It literally isn't possible in C
>>
>>52945039
>size_t n
It was a while ago when I actually write that function, but I'm pretty sure it relies on n being signed, that's why I chose int instead of size_t.
>>
>>52945094
Source is www.ndp77.net/ansi_c/ac00.htm

I haven't posted a "solution" in this thread.
>>
>>52945198
I provided the C89 MASTER RACE solution >>52944861
It's possible but you must convert to the glorious C89 religion before.
>>
File: 66457525[1].jpg (58KB, 250x250px) Image search: [Google]
66457525[1].jpg
58KB, 250x250px
>>52942631
You can do it, anon.
>>
>>52945186
Do you mean using C + POSIX? The standard C library as defined by ISO has no TCP support.
>>
Next up:

Is Scheme portable despite the standard implementation documents being so minimal it's barely even a functional platform?
>>
>>52945186
Using POSIX/BSD sockets? Use beej's networking guide.
For Windows, who fucking knows with that clusterfuck.
>>
File: ss (2016-02-13 at 01.53.17).png (3KB, 101x324px) Image search: [Google]
ss (2016-02-13 at 01.53.17).png
3KB, 101x324px
Is this a joke or can you really get a job simply by being able to do this?
>>
>>52944920
... He literally just told you what the problem is.
Doesn't work on architectures with 64 bit integers.
>>
>>52945198
see >>52944954

works in C89 as well if you remove the final
>>
>>52945198
lol no, you just need a good way to handle negative numbers. I'm sure it's not that hard. Or you just check the numbers if they would overflow and keep the carry.
>>
>>52945160
>Negative numbers
uint average(uint a, uint b)
{
return (a>>1) + (b>>1) + (((a|b)&1));
}

fuck em
>>
>>52945218
>actually write
wrote*
>>
>>52942393
Please stop this programming trap meme.
Thanks.
>>
>>52945229
Not really. The job was described as possible to made in C, and that's my best programming language
>>
>>52944861
int
sgn (int a)
{
return a < 0 ? -1 : !a ? 0 : 1;
}

int
avg (int a, int b)
{
int s = sgn (a) * sgn (b);
if (s <= 0)
return (a + b) / 2;
else
{
int d = (a - b) / 2;
return d < 0 ? a - d : b + d;
}
}
>>
>>52945269
He said ints
>>
>>52945094
>Why nobody dare to criticize my solution?
Because it's shit and not worth reading.

if((a<0) != (b<0)) return (a+b)/2;
return a/2 + b/2 + (a%2 & b%2);
>>
>>52945129
thank mr pypy
http://doc.pypy.org/en/latest/stm.html
>>
>>52943417
Don't listen to >>52943486
Book is outdated and pretty much shit at being a teacher.

Get something more modern that actually understand flow of education and that has at least c99 standard.
>>
>>52945171
>sizeof(short) == sizeof(int) == sizeof(long) == sizeof(long long) == 8
Jesus christ
>>
>>52945327
I want sizeof(char) == sizeof(uintmax_t)
>>
>>52945226
shut you fucking shithole, asswipe, your "master race" solution doesn't work
>>
>>52945296
you can do ( ? : : )?
>>
>>52945366
no and it makes no sense.
>>
>>52945254
sure it does, with long long > 64 bits
now, fuck off
>>
>>52945366

a ? b : (c ? d : e)
a ? (b ? c : d) : e
>>
>>52945171
>sizeof(short) == sizeof(int) == sizeof(long) == sizeof(long long) == 8
kek

but the ints are so big that if you compile a program that was written under assumption that ints won't have more than 16 or 32 bits it will still work on that platform
>>
>>52945250
It's a joke my man, but around here we call them "memes" and use more expletives
>>
>>52945379
Doubles are 64 bits and a lot of compilers would have long longs = ints if you've got 64 bit ints
>>
>>52945259
I am not sure that it is correct. The result of % is not totally defined in C. The standard is not precise about what % must do.

>>52945296
You just obfuscate my code.

>>52945309
Nice. But I'm not totally sure that it's correct for all architecture.
>>
>>52945137
Is there a reason to have shit tons of operations on simple average of 2 objects?
>>
>>52945171
>Tru64 UNIX
http://h41361.www4.hp.com/docs/porting/HP-Porting/CMPCHPXX.HTM
>Table 2-3: Language Data Types
>int 32 bits
>long long 64 bits
>>
>>52945356
provide counter example moron
>>
>>52945420
int avg(int a, int b) { return (a+b)/2; }

...

avg(maxint, maxint)
->
(maxint + maxint -> OVERFLOW) / 2
>>
>>52945382
Oh I see, lack of parenthesis in original code confused me.
>>
>>52945153
> C is portable as long as you follow the standard and don't invoke implementation defined or undefined behaviour.
You can't avoid some amount of implementation-defined behaviour for any practical program.

E.g. whether you can allocate 1K of memory is implementation defined (there are conforming implementations for architectures with less than that). Whether you can read or write files is implementation-dependent (there are conforming implementations for platforms which don't have a filesystem).

If you need more than 1K of memory, your program isn't going to run on something with less than that. If you need files, your program won't run on a system which doesn't have them. And changing language won't help.

People writing actual software tend to at least settle for being portable to anything which satisfies certain constraints which are either inevitable given the problem (e.g. you aren't going to do 4096-bit RSA on a microcontroller with 256 bytes of RAM because you can't even store the key).

Most of them will settle for a lot less. E.g. any architecture whose "int" isn't at least 32 bits is going to be quite starved for software nowadays.
>>
>>52945397
>a lot of compilers would have long longs = ints if you've got 64 bit ints
>a lot of compilers
give me 3 examples
>>
>>52945431
>ruby blown the fuck out AGAIN
just not his year
>>
>>52945463
give me examples of 64 bit int compilers
>>
It's 2016, why don't you have a GitHub?
>>
>>52945416
>Nice. But I'm not totally sure that it's correct for all architecture.
I said bullshit. It looks like it's C89 legit.
>>
>>52945436
if you can't see (a - b) / 2 is just as bad as (a + b) / 2, you can't be helped
>>
>>52945416
>..., the result of the / operator is the algebraic quotient with any fractional part discarded ... (This is often called "truncation toward zero".) C11dr §6.5.5 6
>The result of the / operator is the quotient from the division of the first operand by the second; the result of the % operator is the remainder ... C11dr §6.5.5 5
you can still use (i - i / 2 * 2)
>>
>>52945485
why should I? ask the faggot that started talking about "lots of compilers with 64 bit ints"
>>
>>52945492
Have you seen the shitstorm hitting github recently?
>>
>>52945498
looks like it checks the signs first. if a and b have opposite signs, it's safe
>>
>>52945416
>The result of % is not totally defined in C
it is completely defined
>>
>>52945509
You wanted examples, I didn't because I was talking about standard compliance
>>
>>52945446
check the values of a and b before you call the function, and if their addition might cause problems, print something to stderr and call exit.
>>
>>52945492
i don't need it

i don't want to support zionist SJW faggotry

actually i have one but i just registered and never used it
>>
>>52945455
>Whether you can read or write files is implementation-dependent
just check the return value of fopen you fucking faggot

>whether you can allocate 1K of memory is implementation defined
just check the return value of malloc you fucking faggot
>>
>>52945525
look again, you blind fuck
>>
Wait a minute, should I be rounding up or away from 0?
>>
>>52945514
Yeah, but it's 2016.

You can't find a job without a GitHub.
>>
>>52945533
That's really dumb, and doesn't even do what the original question asked.
>>
>>52945498
Not in my case. There are checks before. Shut the fuck up moron. We're not at the same level.

>>52945501
Yes yes, I agreed >>52945493 here. Your solution is nice. But I still need to find the definition of algebraic quotient and fractional part to be 100% sure.
The same for >>52945528
>>
>>52945530
still waiting on that list of "a lot of compilers with 64 bit ints"
>>
>>52945549
He never asked you to round.
>>
>>52945545
i didn't read it thoroughly but it does (a - b) if they have the same signs so it's safe you dumbass
>>
>>52945566
I said if they've got 64 bit ints
>>
>>52945560
>I still need to find the definition of algebraic quotient and fractional part
>we're not at the same level
you got that right
>There are checks before
yes, and you march on with overflow, like a dumb fuck
>>
>>52945597
if opposite signs: a + b is safe
if same signs: a - b is safe
>>
>>52945579
>it does (a - b) if they have the same signs
true
>so it's safe
false
>dumbass
looks like you're it
>>
>>52945574
>He never asked you to round.
Brilliant
int average(int a, int b)
{
if ((a|b)&1) exit(0);
return a/2 + b/2;
}
>>
>>52945597
>yes, and you march on with overflow, like a dumb fuck
You repeating like a parrot. But You're incapable to provide a counter example. I accept fictional architecture that respect C89 standard. It's not because you repeat something 100 times that it's true.

It's still you
>>52945614
>>so it's safe
>false
COUNTER EXAMPLE

>>52945560
>algebraic quotient and fractional part to be 100% sure.
Found it.
>>
>>52945614
when is it not safe? if both numbers are negative it's safe and if both numbers are non-negative it's safe
>>
>>52945446
problem I see is -3/2 is -1

You can't do this with int, check if sum exceeds INT_MAX and if i does then do (a/2) + (b/2) if not do normal (a+b)/2
>>
>>52945625
Why not use the exit code to put the 0.5 bit
>>
>>52945587
ah, so you don't have any example for your "a lot of compilers" assumption
then, why would you assume that long long is 64 bit if int is 64 bit? why wouldn't long long be let's say 128 bit?
>>
>>52945549
truncation which is rounding toward 0, same as with /
>>
>>52945625
You're supposed to return a float, dummy.
>>
>>52945664
"and a lot of compilers would have long longs = ints if you've got 64 bit ints"
>would

Calm down OCD freak
>if
>>
>>52945664
This just silly.
>>
>>52945664
"64 bits are probably enough" logic
>>
>>52945664
>>52945740

Not to mention that native ints are usually more efficient
>>
>>52945714
yes, "a lot of compilers have 64 bit int and 64 bit long long" is silly
>>
To compute the average of a list of ints, just use rationals.

https://hackage.haskell.org/package/base-4.8.2.0/docs/Data-Ratio.html
>>
>>52945696
>would
based on what?
>>
>>52945798
based on 64 bits being enough for a long long, being the same as what most other compilers would have for long long
>>
guidelines for writing portable C that covers 99.99% of the implementations you'll run on:

char = 8 bit
short = 16 bit
int = 32 bit
long = 32/64 bit
long long = 64 bit
2's complement representation
done
>>
>>52945812
following the same reasoning: 32 bits is enough for int, being the same as what most other compilers have for int
>>
>>52945830
or, you could just use types that have guaranteed, well defined sizes.
>>
>>52945830
until you rely on modular arithmetic for unsigned ints and then suddenly a platform has 64 bit ints

why not just use stdint.h?
>>
>>52945830
>int = 32 bit
We're at the 64bits era. int should be 64bits on 64bits CPU.
>>
return a/2 + b/2 + ((a|b)&1) + (-1*(a&1&&a<0)) + (-1*(b&1&&b<0));
rounds towards 0 for .5
>>
>>52945854
those are the guaranteed, well defined sizes
>>
>>52945830
triggered
>>
>>52945865
>int = 32 bit
>guaranteed
>well defined
>>
>>52945854
you could sizeof everything you need.
>>
>>52945849
native ints are normally faster, there's a minimum for ints but no maximum
>>
>>52945861
>suddenly a platform has 64 bit ints
no, a platform doesn't suddenly have 64 bit ints
>>
>>52945876
a new platform you insufferable sperg
>>
>>52945862
>int should be 64bits on 64bits CPU
spoken like a memejs retard
if int is 64 bits, what standard type would you use for 8, 16 and 32 bits? there's only char and short left and you need to cover 3 sizes
>>
>>52945897
I don't care about those sizes.
>>
>>52945873
but non-native ints might be slower, there's a minimum for ints but no maximum
>>
Is ptrdiff_t just a signed size_t?
>>
>>52945895
nope, no new platform will have 64 bit ints
>>
>>52945915
parallelism?
>>
>>52945897
>spoken like a memejs retard
int used to be the word size until sandnigger codemonkeys started getting into C.
end yourself
>>
>>52945933
What?
>>
>>52945915
of course, that's why you're a web monkey
>>
>>52945919
no
>>
>>52945919
in practice, yes
>>
>>52945944
with 16 bit ints you can fit 4 in one 64 bit register
>>
>>52945948
honest question, why would you care about 8bit size on 64bit CPU?

I can understand 16 and 32bits but 8?
>>
>>52945327

Yes, well, there's reasons it's a dead platform.
>>
>>52945966
So impressive. That's a thing I want to do every day. I have a 16GB ram with archlinux. I'm really short with memory.
>>
>>52945967
why wouldn't you? and a char is always 1 byte
>>
>>52945897
>what standard type would you use for 8, 16 and 32 bits?
intN_t typedefed to an extended integer type.
>>
>>52945939
>until sandnigger codemonkeys
thank god; at least they used their brains instead of cargo culting on "machine word size"
"hey guys, it's really handy to access data in 8, 16, 32 bit quantities even though the native register is 64-bit wide; should we be reasonable and not take away the option for accessing them or say fuck it and don't let them touch 16-bit or 32-bit stuff in the name of purity?"
>>
>>52945979
>>52945465
>>
>>52945967
because text? fucking webfag
>>
>>52945966
Then you would use 64 bit types.
>>
JS question:

How would I arrange an array like this in alphabetical order - based on the strings stored in index 1 of each subarray:
var newInv = [
[2, "Hair Pin"],
[3, "Half-Eaten Apple"],
[67, "Bowling Ball"],
[7, "Toothpaste"]
];
// changed to be alphabetically ordered
var newInv = [
[67, "Bowling Ball"],
[2, "Hair Pin"],
[3, "Half-Eaten Apple"],
[7, "Toothpaste"]
];
>>
NEW THREAD >>52946036
>>
>>52945998
intN_t has additional restrictions over the standard types
>>
>>52945983
no, i mean registers in the cpu

if i've got 8 ints:
a b c d
and
0 1 2 3

and i want
a & 0
b & 1
c & 2
d & 3

i can just do

(a | b | c | d) & (0 | 1 | 2 | 3)
(by | I don't mean or, I mean the bytes side by side)
>>
>>52945987
exactly, char is your 8bit int.

why do you need 8bit int if you have one?
>>
>>52946001
You know shit m8.
>>
>>52946036
>>52946036
>>52946036
>>52946036
>>
>>52946018
>>52946055
>>
>>52946062
back to css, pajeet, this is over your head; that's why webcuck don't have a say in cpu design; you just lack knowledge and reason
>>
>>52946050
I thought you wanted those restrictions.
Standard integer types aren't guaranteed to be of any particular size.
>>
>>52945465
>>52946009

You're going to re-post one of my typos? And I've been here since 2006.

>>52945967

UTF-8, dipshit.
>>
>>52946094
What typo?

DID YOU MAKE ANOTHER MISTAKE?
>>
>>52946083
>wanted those restrictions
you don't even know what restrictions I'm talking about
>>
>>52946116
>you don't even know what restrictions I'm talking about
enlighten us
>>
>>52946056
how fucking stupid are you? char IS the 8 bit int were talking about
>>
>>52946055
And that would mean using 64 bit ints if you want the & '4-wide' in a single instruction.
>>
>>52946055
I'm fucking impressed by your skills at optimizing code.
>>
>>52946126
besides the fixed size, it must also have no padding bits and a 2's complement representation regardless of the native representation of the machine
>>
>>52946134
its always 8bit min, always.
>>
>>52946138
... the individual parts would be 16 bits
>>
>>52946116
Exact bit width?
Otherwise you could just use 64 bit ints for everything by masking out bits you don't want.
>>
>>52946110

Yeah. Repeated half my life twice. The first instance was supposed to be that I was close to 10 years here.
>>
>>52946165
2'S COMPLEMENT REPRESENTATION YOU DENSE MOTHERFUCKER
>>
>>52946144
this is pretty standard
>>
>>52946163
... packed in a 64 bit int, otherwise you wouldn't get the single AND.
>>
>>52945872
Bytes aren't guaranteed to be 8 bits.
>>
>>52946178
What does that have to do with anything?
>>
>>52946168
"I'll have spent half my life here"
"So you've been here since 2010?"
This implies that half your life is 6 years, making you 12.
>>
>>52946179
>>52946179
It depends of what you're doing. But having int 64bits doesn't prevent that.
>>
>>52946162
it's at least 8 bits, m8
>>
>>52946207
yeah, who cares about representation, amirite? certainly not css cucks!
>>
>>52946182
>>52946210

yes, obviously you also use a 64 bit int
you want 16 bit ints for type and value safety
>>
>>52946178
>>52946160
So, basically, it guarantees exact type width.
>>
>>52946212
because char is an array.
1 segment of that array is always 8bits long.
>>
>>52946193
Are you Jesus C. Christ?
>>
>>52946245
Nope, it's guaranteed to be at least 8 bits.
Bytes aren't guaranteed to be 8 bits, just at least 8 bits, for some reason.
>>
>>52946242
So, basically, you're too dumb to be part of this conversation.
>>
>>52946234
There's these magical operators &, |, ~, ^ which can synthesize any integer representation you want anywhere *in* the integer you want.
But you must be older than 5 to understand how they work.
>>
>>52946236
>you want 16 bit ints for type and value safety
What fucking safety?
You would only use 64 bit ints otherwise you wouldn't get any speed benefit.
>>
>>52946208

I'm 24. I've been here since late 2006, so almost 10 years. In a few more years, I will have spent half my life here.
>>
>>52946277
>I don't know what different value representation requirements for 2 integer types imply, but I'll just shitpost some stuff about these magical operators I've found out yesterday that can make shit up, never mind I can't actually access the value and still have it make sense, but meh, such is the life of webcucks
kill yourself already
/thread
>>
>>52946297

The type should represent the range of values
As an example, if you're representing your 16 bit ints as 64 bit ints before putting them together, you might end up with a bit set outside of the 16 bit range, or similar
Thread posts: 413
Thread images: 20


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