[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y ] [Search | Home]
4Archive logo
/dpt/ - Daily Programming Thread
If images are not shown try to refresh the page. If you like this website, please disable any AdBlock software!

You are currently reading a thread in /g/ - Technology

Thread replies: 341
Thread images: 28
File: THERE'S STILL HOPE.png (572 KB, 852x478) Image search: [iqdb] [SauceNao] [Google]
THERE'S STILL HOPE.png
572 KB, 852x478
IGNORE ALL NON-PROGRAMMING/POLITICS POSTS

Previous thread: >>52916111

What are you working on, /g/?
>>
ANIMUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU TRAPPPPPPPPPPPPPSSSSSSSSSSSSSSS!
>>
Still fiddling with my idle-game AI. I'm trying to come up with a method of job priority that isn't just an enumerator and counter check.
Perhaps a way to designate "goals" and assigning resource collection based on the goal or something.
>>
>https://losc.ligo.org/s/events/GW150914/GW150914_tutorial.html

LIGO researchers use Python.

Why don't YOU?
>>
int avg(int a, int b) { return a + b / 2; }
did I do good, /g/?
>>
IGNORE ALL PYTHON/SCRIPTING/WEBDEV/BAIT POSTS
>>
>>52921590
Because it's slow
>>
>>52921600
Nice bait mate
>>
>>52921622
rate me fgt!
>>
>>52921590
B-but I do

>>52921611
import numpy as np
>>
>>52921600

avg(2147483647, 2147483647);


Tell me what that produces.
>>
>>52921524
Thanks, this is pointing me in the right direction. I noticed vector was running destructors and reallocting but I didn't put 2 and 2 together and realize it was invalidating that reference. Taking the reference after adding the other element fixed it.
>>
>>52921633
kill yourself
>>
>>52921639
2147483647, as expected
>>
>>52921600
For fuck sakes, 4chan is ded and your code is shit.
>>
>>52921668
what's wrong with it, m8?
>>
>>52921653
http://ideone.com/szrC0Q

kill yourself
>>
Am I missing something? Why would you even bother with REST why you could use RPC? It seems much better on paper.
>>
>>52921691
>unironically using "web apps" to compile
fuck off, shitlord
>>
>>52921680
This is how compiler will see your code.
return a + (b / 2)

because operator / takes precedence over +
>>
>>52921692
>muh soap
>muh wsdl
>muh tag soup
well memed
>>
>>52921653

Try it with INT_MAX instead. You may be using Tru64 Unix.
>>
>>52921720
>got mad for getting told
fuckin no lifer
>>
>>52921729
the nigger is just an arrogant entitled millennial that didn't even run it

notice the lack of parentheses

>>52921744
kill yourself
>>
>>52921713
there are no parentheses in the code, moron
>>
>>52921720
nice argument faglord
>>
>>52921754
people like this are allowed to not die

>>52921759
kill yourself
>>
>>52921729
what is INT_MAX?
>>
>>52921754
kek

so you think this: 2 + 10 /2 is what? 6 ?

fucking retard
>>
>>52921754
>>
>>52921749
>implying the ability to do better
I dare you fgt
>>
>>52921768
>allowed meme
who's allowing, fgt? who's denying? nothing? thought so
fucking pedophile scum
>>
File: fuckyea.png (32 KB, 472x404) Image search: [iqdb] [SauceNao] [Google]
fuckyea.png
32 KB, 472x404
Results of a two-day code clean-up operation: 561 lines deleted, 0 added. All tests pass.

Feels good man.
>>
>>52921790
we've done this a gorillion times already you newfag

i don't remember if this is entirely correct:

int avg(int a, int b) { return a / 2 + b / 2 + (a % 2 + b % 2) / 2; }
>>
>>52921776
yes, do you fucking know math? 2 plus 10 is 12, divided by 2 is 6
you should be banned from /g/
>>
>>52921770

Platform dependent constant that indicates the largest value that can be stored in an int. It's defined in limits.h
>>
>>52921803
our governments you insufferable retard

>>52921820
kill yourself
>>
>>52921816
>don't remember if this is entirely correct
>if
>correct
fuck off with your broken shit; test it first and then come back
>>
File: hipster trash.jpg (47 KB, 400x516) Image search: [iqdb] [SauceNao] [Google]
hipster trash.jpg
47 KB, 400x516
>>52921607
Python is turing complete, though.

You're not one of those people who hates things because they're popular, are you? Hmm, if only there was a word for that
>>
>>52921829
>muh government
>do something
>noooo, don't take muh animu, I need to jerk it to kids
fuck off and die in a fire, shitstain!
>>
>>52921834
how about no. how about you test it yourself if you're so interested in averaging two ints in C
>>
>>52921820
grab the calculator and to the math faglord
>>
>>52921847
>needing a calculator for simple addition and division
m8, you might want to leave /g/
>>
>>52921842
all the good languages are more popular than python. you're the real hipster if you think python has any credibility as a programming language
>>
>not using an anime image
>>
>>52921844
>here's some code I threw up
>test it for me, I can't be bothered
>it's good though
fuck off, webshit
>>
>>52921855
https://www.google.com/search?q=2+%2B+10+%2F+6

m8, you might want to kill yourself
>>
>>52921857
>used ubiquitously in data analysis and almost all science fields
>no credibility
lolk
>>
>>52921857
>good languages are more popular than python
so, python is more popular than python? were you dropped?
>if you think python has any credibility
bwahahahahahaha, sure thing, csscuck
>>
>>52921868
as if yours was even half-way decent lmfao
>>
>>52921816

Something like that, except it breaks on integers of different signs IIRC. This is what I use:

#include <stdint.h>

int64_t signed_average(int64_t a, int64_t b)
{
// If a and b are not the same sign, we can safely add without overflow.
if ((a < 0) != (b < 0)) {
return (a + b) / 2;
}

// Otherwise, we take advantage of a particularly useful mathematical
// property: (a + b) / 2 is the same as (a/2) + (b/2). We will use a
// modulus to account for averaging two odd numbers.
else {
return (a/2) + (b/2) + (((a%2) + (b%2)) / 2);
}
}


And as a macro:

#define avg(a,b) ((a<0)^(b<0) ? ((a+b)/2) : ((a/2)+(b/2)+(((a%2)+(b%2))/2)))


Fucking modular arithmetic, man.
>>
>>52921887
sure it was, it's elegant and concise; yours is a pile of shit that most likely doesn't even work
>>
>>52921607
>>
>>52921909
yours barely works, like, at all. did you even run it?
>>
>>52921607
This thread needs less webdev and more anime
>>
>>52921893
#include <stdint.h>

int64_t signed_average(int64_t a, int64_t b)
{
return ((a < 0) != (b < 0)) ? ((a + b) / 2) :
(a/2) + (b/2) + (((a%2) + (b%2))/ 2);
}
>>
File: 3dpd.jpg (192 KB, 480x640) Image search: [iqdb] [SauceNao] [Google]
3dpd.jpg
192 KB, 480x640
Is Clojure worth learning? What's the best resource for learning it?
>>
>>52921957
no

how did you even come up with the idea that <obscure meme lang> could possibly be worth learning?
>>
>>52921600
Your code is shit. Observe true autism at work:
int avg(int a, int b)
{
return (a >> 1) + (b >> 1) + (a & b & 1);
}
>>
>>52921982
only works for unsigned integers
>>
What is the masculine programming language and why is it x# with assembly?
>>
>>52921519
trump and sanders are the only decent electable candidates
>>
So, I'm down to learn how to program something, where do I start? Is Code Academy a good place to learn Java/C/C++? Any tips?
>>
>>52922036
codecademy is shit

https://docs.oracle.com/javase/tutorial/
>>
File: c9e.gif (3 MB, 500x500) Image search: [iqdb] [SauceNao] [Google]
c9e.gif
3 MB, 500x500
>>52921970
Because this is /dpt/, home of smug anime girls and meme functional programming
>>
>>52922036
Code academy is awful.

Start with python or java. Look up some books you can find online for free

Once you feel good then move on to c++ to learn oop and data structures then never look back
>>
>>52922093
don't start with python

python is shit
>>
>>52922068
We have to defend /dpt/. People are starting to like and post non anime images and we have to do something about it.
>>
>>52922107
Yeah python is shit but to first start out in programming it's probably the easiest to understand due to how liberal the syntax is
>>
>>52922121
This would never have happened if you had just let the trap poster post the new thread every time.
>>
>>52922093
>Start with python or java. Look up some books you can find online for free

Why do you people say this?

Why not just start with C++ and be done with it.
>>
>>52922151
stringency and consistency is better for learning imo
>>
>>52922177
Because starting out with c++ is literally the most difficult thing you could ever do without any knowledge of programming.
>>
>>52921519
I code for the bern
>>
It's time to ask your beloved programming literate anything.

>>52921790
>>52921816
int average (const int x, const int y) 
{
if ((x > 0) == (y < 0))
return (x + y) / 2;
const int xh = x / 2;
const int yh = y / 2;
const int xhr = x % 2;
const int yhr = y % 2;
return xh + yh + (xhr & yhr);
}


>>52922036
just pick one of the following.

:: Structure and Interpretation of Computer Programs
http://sarabander.github.io/sicp/
http://paste.lisp.org/display/151208/raw

:: How to Design Programs
http://htdp.org/
https://www.edx.org/xseries/systematic-program-design-0

:: Concepts, Techniques, and Models of Computer Programming
not free

:: Composing Programs
http://composingprograms.com/

:: CS for All
http://www.cs.hmc.edu/csforall/
https://www.edx.org/course/cs-all-introduction-computer-science-harveymuddx-cs005x

:: Program Arcade Games With Python And Pygame
http://programarcadegames.com/
>>
>>52922211
How is it more difficult than Java?
>>
>>52922233
Memory management for one.
>>
>>52922177
You start with C.
It has no abstractions that get in the way of learning.
You should never use abstractions without first understanding what you're abstracting away.
>>
>>52922233
java is simpler, stricter, has superior error messages with real-time feedback in the IDE, easy to understand documentation
>>
About what level of knowledge would you consider someone to be 'experienced in' a programming language?

I put on my resume that I'm experienced in C++ and C# because I consider those my "main" languages, but I've never done anything more complicated than a rudimentary text editor in either. I understand a lot of the concepts but working them all together isn't something I've done much of. Will this matter?
>>
>>52922253
but programming is mainly about abstraction.
>>
>>52922036
Start with assembly my man
>>
File: 1437683162905.png (29 KB, 633x758) Image search: [iqdb] [SauceNao] [Google]
1437683162905.png
29 KB, 633x758
>tfw too stupid to make an animated decal in libgdx
>the wiki documentation is nonexistant for animated decals
>google doesn't come with anything
>>
>>52921600
The best part of this is that it isn't correct even if you ignore the 'overflow' problem.

If you ask this function to find the average of 8 and 12 it'll return 14.
>>
>>52922274
Programming is about building abstractions.
>>
>>52922273
actually being experienced: 3+ years of working in that language

"experienced" enough to put on a resume: about the same as you because you know everyone else are bullshitting too
>>
>>52922300
Well in that case I guess I'm good. Thanks anon. I assume a job would teach me anything I don't know anyway.
>>
>>52922291
>he fell for the libgdx scam
>>
is anyone aware if pqxx still has memory leaks problems? i am currently compiling with pqxx-4.0 and it still leaks, code is good, it's literally a cycle, tried calling clear and deleting on pqxx::result and it doesn't change, running it on valgrind as of now
>>
>>52921633
muh nigga
>>
File: g user 8.jpg (165 KB, 1440x1440) Image search: [iqdb] [SauceNao] [Google]
g user 8.jpg
165 KB, 1440x1440
I got a C test tomorrow. Wish me luck...
>>
>>52922514
show us your code, fukboy.
>>
Fun fact: 90% of the people who hate python don't (or barel) know it
>>
>>52922514
This is what happens when pythonfags write C.

For all you pythonfags out there here's how you would actually write this.

int main(void)
{
int i;
int j;
i = 0;
j = i;
while(0x4)
{
if(j == 0)
{
printf("%i", ++i);
if(i == 5)
{
j = 1;
}
} else {
printf("%d", --i);
if(i == 0)
{
break;
}
}
}
>>
I'm learning to code, is this 'popular culture of the internet' thing legit /g, it's not really mentioned anywhere online. But I got my program to run I guess and it worked, so I must be doing something right. https://www.youtube.com/watch?v=Er6R5R06Q8I
>>
>>52922630
int ctr = 0;
for (; ctr < 5; ctr++)
printf("Counter is at %d\n", ctr);
for (; ctr <= 0; ctr--)
printf("Counter is at %d\n", ctr);
>>
>>52922665
What the fuck is this garbage?
>>
>>52922630
>using break;
>>
>>52922678
Fudged up that there inequality sign.
>>
>>52922665
>python
Dropped.
>>
>
int main(void)
{


WHY PUT A { ON AN INDENT?
>>
>>52922665
the fuck are you talking about
>>
Quastion
why is
    for(int i = 0;i < 5;i++){
printf("%d\n", i);
}

different from
    for(int i = 0;i < 5;i++,printf("%d\n", i))
;
>>
>>52922688
Is he wrong then? I kind of presumed so. I feel pretty dumb for spending the last 15 minutes coming up with the most popular memes on google search trends. It can't be all fake though because it worked, there's an element of truth to it so I think I'll stick with the tutorials
>>
>>52922736
It's an altered Emacs indentation style. In the original brackets were indented twice and the subsequent code blocks were indented twice again. The idea was to solve the dispute between '2-space' against '4-space' by using aspects of both. It actually looks really nice in a properly styled Emacs code block.

Anon went full shitface by making it three spaces instead of two, though.
>>
Does brainfuck use unsigned or signed chars for it's cell array?
>>
>>52921805
>delete functions that are never called
>remember why you added them
>no backups
I'd say something about storage, but even OpenSSH got bit in the ass by old code.
>>
>>52922747
for(pre; cond; post)
i++ is called after the first execution of the loop body
>>
>>52922747
in the sec0ond case the printf is execute at te end of the for

immagine the for as a while loop. the first thing that is executed is the i = 0
then there's the while loop
and then the i++ (and the printf())
>>
>>52922765
What the fuck are you saying?
>>
>>52922747
The second is a compiler error, while the first isn't.
That being said you could easily replace both with

for(int i = 0; i < 5; printf("%d\n", i++)){}


You can do a lot of clever things with For loops in C. The problem is most of those things are, while clever, also very hard to follow and thus bad practice.
>>
>>52922765
No anon he's completely right, faggots in this thread telling you otherwise are normies who have never operated a low level language. 'The popular culture of the internet', i.e memes are an essential part of programming. You need at least 100 memes per program. Stick with the tuts and good luck man
>>
How do I get JavaFX to work in an OSGI Project?
Could use Swing and SWT but JavaFX seems to be a problem because it shows ClassNotFound Exception already at "Class X extends Application".
I just want to Hello the fucking World
>>
>>52922783
~version control~

>>52922798
You are getting memed son.
>>
>>52922772
Anyone who doesn't use
type function()
{
return;
]

style of programming should get shot.
>>
>>52922776
It doesn't matter because 0 is the same in both unsigned and signed and brainfuck has no comparisons that don't use 0.
>>
>>52922808
Ok I will, thanks I guess, I just needed some reassurance. It made sense to me when I watched the video but after I felt a little skeptical, who wouldn't? Well thanks anyway, I think I'll keep watching this series and I want to make a game with what I learn from it
>>
>>52922794
>immagine the for as a while loop
While loops are just gotos. If we're doing syntax insulin here we might as well go all the way.
for(int i = 0; i < 5; ++i) {
printf("%d\n", i);
}

is really just
int i = 0;
a: if(i >= 5) goto b;
printf("%d\n", i);
++i;
goto a;
b:
>>
>>52922830
Anyone who doesn't use
(defun function ()
()
)

style of programming should get shot.
>>
>>52922807
>The second is a compiler error, while the first isn't.

No it is not, it's perfectly legal operation.
>>
>>52922898
Anyone who uses obscure meme languages should get shot. Good luck finding a job >:^)
>>
>>52922872
Yup 10/10
>>
>>52922917
>meme languages
>literally had an entire industry of computers built around them
ok
>>
>>52922830
>not
auto functionname() -> type
{
return;
}


Get out of here with your dinosaur shit. It's not scalable.
>>
Need some technical programming interview questions.
>>
>>52922872
Fucking hell, and they say that /dpt/ is useless, I already learned something very important.
>>
>>52922945
'Here's a whiteboard anon, can you write out a fizzbuzz program in your language of choice? You have ten minutes.'
>>
>>52922935
Basic was used for the BBC micro. But take a look at how many BBC micros are being used today.
>>
>>52922935
"an entire industry" that went belly up within two decades
>>
>>52922736
he is just retarded, don't stare at him or he'll get scared
>>
>>52922955
Yep. And if you want to be REALLY technical, assembly language has a few jump opcodes that have built-in comparators (imagine goto and if combined in one command), they just work slightly different than a typical if. Both goto, while, and for all compile down to these basic jump commands so they're all mechanically identical, even if they're very different syntactically.
>>
Are there any good learning/practice resources for OO design? Books, lectures, etc.

Whenever I try to do a personal project in Java I end up writing most things in static methods. I'm just too used to the procedural style that it seems weird to encapsulate functions within objects, and so I end up ignoring all the other major OO features.
>>
>>52922962
That's a shit example, considering a dialect of BASIC is currently one of the most used programming languages out there.
>>
File: experiments.jpg (23 KB, 435x475) Image search: [iqdb] [SauceNao] [Google]
experiments.jpg
23 KB, 435x475
how do i motivate myself to code things?

actually, how do i motivate myself to much of anything?
>>
>>52922957
Easy
def fizzbuzz(num):
if num%15==0: return fizzbuzz(num-1) + "fizzbuzz\n"
if num%3==0: return fizzbuzz(num-1) + "fizz\n"
if num%5==0: return fizzbuzz(num-1) + "buzz\n"
return fizzbuzz(num-1) + str(num)
>>
>>52923019
Step 1 in OOP is to not use Java. It's pants-on-head retarded for basically everything OOP related.

The point of OOP is to have reusable data types, not reusable functions, so forget any idea you ever had about 'static classes'. They're memes.

For a good-example-but-shitty-program example of OOP, think of a program that store bank account information for clients. You would have an 'account' class with various data and functions associated with it, and when a client wanted to open a new account you'd create an instance of the account class with the data they provide. C# is nice for stuff like this, in that it's OOP-oriented but not retarded like Java is.
>>
>>52923066
>recursion
'Sorry anon, you're too white for this job.'
>>
>>52923066
I'm a HR person, since this doesn't match the Java code snippet I got from the programmers you failed.
>>
>>52923027
>a drag and drop simulator is a programming language
>>
File: shia.jpg (44 KB, 800x465) Image search: [iqdb] [SauceNao] [Google]
shia.jpg
44 KB, 800x465
>>52923063
just make it so
>>
>>52923066
>>> fizzbuzz(10000000)
RecursionError: maximum recursion depth exceeded in comparison

you didn't get the job
>>
>>52923116
t. python
>>
>>52923019
>Whenever I try to do a personal project in Java I end up writing most things in static methods.
Don't do this, first of all.

If you want a fun personal project, try making an MMO. I know that sounds like bullshit advice, but I don't mean you should make an actual playable MMO. Just hook your program up to a database (another important thing to learn about), and write classes for things like characters and stats, inventories, items that can be stored in those inventories and so on.
You don't even need to be able to connect any clients to it, just the server portion is enough for OOP design practice, but if you want to you can learn some network programming by letting clients connect and trade items or gold with eachother.
Obviously this isn't a suggestion for beginners but since you have experience with procedural style languages you could probably do this.
>>
>>52923176
>no TCO support
What are you coding in, java?
>>
>>52923066
print(["FizzBuzz" if i % 15 == 0 else "Fizz" if i % 3 == 0 else "Buzz" if i % 5 == 0 else i for i in range(1, 100)])
>>
File: fizzbuzz.jpg (103 KB, 1075x1689) Image search: [iqdb] [SauceNao] [Google]
fizzbuzz.jpg
103 KB, 1075x1689
>>52922957
>>
>>52923229
he posted python
>>
>>52923238
work on your handwriting
>>
>>52923255
If there's one thing I like more than shitting on python it's shitting on java.
>>
>>52921982
>>52921995
let's not forget that it compiles into the exact same thing if you specify unsigned int
>>
Are you using memes in your programs /g?
https://www.youtube.com/watch?v=Er6R5R06Q8I
>>
>>52923176
from sys import setrecursionlimit
setrecursionlimit(10**999999999999 ** 99999999999)

That should be enough recursion.

>>52923236
Remove the brackets and you'll get a slightly more optimized version
What you have is equivalent to
print(list("FizzBuzz" if i % 15 == 0 else "Fizz" if i % 3 == 0 else "Buzz" if i % 5 == 0 else i for i in range(1, 100)))
>>
>>52923019
>end up writing most things in static methods
Fun fact: in modern Java development you usually don't make a method static even if you can (because it hinders dependency injection)
>>
Is this a proper use of the switch statement?
bfuck_t interpret_cmd(const char c)
{
bfuck_t cmd;
switch (c)
{
case '>': cmd = INCREMENT_PTR; break;
case '<': cmd = DECREMENT_PTR; break;
case '+': cmd = INCREMENT_DATA; break;
case '-': cmd = DECREMENT_DATA; break;
case '.': cmd = OUTPUT_DATA; break;
case ',': cmd = ACCEPT_DATA; break;
case '[': cmd = LEFT_BRACKET; break;
case ']': cmd = RIGHT_BRACKET; break;
default : cmd = INVALID_COMMAND; break;
}
return cmd;
}
>>
>>52923063
>how do i motivate myself to code things?
wtf, that's like asking "how do I motive myself to go to the bathroom". Just wait a day or so until the urge to program is so strong you can no longer bear it.

If that doesn't happen, quit CS
>>
>>52923372
yeah, arguments and stuff like that are all a switch statement is really used for since each case does something completely different.
>>
>>52923329
>>> from sys import setrecursionlimit
>>> setrecursionlimit(10**999999999999 ** 99999999999)
OverflowError: Python int too large to convert to C long

come on anon, you can do better than this.
>>
>>52921519
>ignore all politics posts
>OP
guess I'm outta here
>>
>>52923423
/ has precedence over - you tard
>>
>>52923388
I've been coding for years, I used to have those kinds of urges.

Nowadays I just get uncaring when I try to code.

I guess I'm just broken, is this not normal?
>>
File: nM8S4yb.jpg (609 KB, 4160x3120) Image search: [iqdb] [SauceNao] [Google]
nM8S4yb.jpg
609 KB, 4160x3120
>>52923238
>using more than one line
your code wouldn't even fit on a small enough whiteboard, senpai
pic related is what you should have wrote
>>
>>52923476
You're clinically depressed.
>>
>>52923566
Stop, you are giving me flashbacks to writing out 15 pages of java code by hand for my college exams.
>>
>>52923590
I've been thinking so, I've just been needing someone else to tell me it.

What should I do? I'd like to code things again.

Is there an (effective) alternative to a psychiatrist?
>>
File: Selection_094.png (6 KB, 336x95) Image search: [iqdb] [SauceNao] [Google]
Selection_094.png
6 KB, 336x95
What does this code do, /g/?
>>
>>52923591
Wow, seriously? For my class the programs or functions we wrote always fit on one page.
>>
>>52923644
>Is there an (effective) alternative to a psychiatrist?
Not really. Drugs can make you believe it isn't real but they can't actually help you.
>>
>>52922227
>literate
>can't average 2 ints
end yourself pedofag
>>
>>52923646
i still prefer slides to
>>
What does the comma operator do in brainfuck?
Where is it getting it's data from?
>>
>>52923646
It's undefined behaviour.
>>
>>52923672
Our finals were 6 hour exams. For some of them I ended up with 10-15 pages of "code" that looked like >>52923566
Not all for one problem though, I'm talking about for the entire exam.
>>
>>52923723
stdin, usually.
>>
>>52923727
Obviously. I'm just ondering what it actually DOES.
>>
>>52923646
adds x to itself and x + 1. increments x a total of three times

returns x + 1. increments twice more.
>>
>>52923773
Then compile and run it you dumb fuck.
>>
>>52922036
Sololearn.com
>>
>>52922318
>>52922291
What's wrong with libgdx?
>>
>>52923773
It's undefined behaviour, which means that there are no meaningful results.
>>
>>52923750
so it accepts 1 byte during runtime?
Do you stop the program and ask the user for that byte?
>>
>>52923673
I'm just going to have to do it.

Thanks anon, I've been needing this for a long time.
>>
>>52923780
It just gives me errors. I adjusted it to an error-free version, which isn't quite as interesting:
int goes_to_very_quickly(int x) {
int *px = &x;
++*px++;
*px++ += *px++ + ++*px;
return px++;
}

int main(int argc, char *argv) {
printf("%i\n%i\n%i\n", goes_to_very_quickly(1), goes_to_very_quickly(5), goes_to_very_quickly(100));
return 0;
}


This compiled successfully and wrote the following to stdout:

328752648
328752648
328752648



I'm satisfied.
>>
>>52923823
It works almost exactly the same as C's getchar() function.
>>
>>52923644
>>52923644
Exercise. Eat. healthy. Set up a daily routine. Set goals. Do something different for awhile.

You can take pills but it may take several months to find something that really hits the spot. Then you have to justify it. Its a facade. It only deters your depression. You'll be hiked up on more and more.
>>
Daily reminder: objects
>>
>>52923113
But you said language of choice!
I demand to see the manager.
>>
>>52923936
I'm so far gone that anything a bit hard I just go meh on, definitely after though once I can get myself in order I will do that.
>>
File: 1364508011124.jpg (75 KB, 600x688) Image search: [iqdb] [SauceNao] [Google]
1364508011124.jpg
75 KB, 600x688
Using C#:

Resources A, B, C, and D exist.
Workers collect resources A and B.
It is determined Building 1 needs to be built.
Building 1 (and all other building objects) and stored within a dictionary.
Inside that dictionary is another dictionary of Resource requirements (rather than just using a list of KeyValuePair. Same thing).
There is a separate dictionary of Worker Jobs, each of which specifying what Resource the jobs collects.

How should I pair all this shit up if Building 1 requires resource C and D instead of A and B?
My ideal is that I examine my current resource stockpile of C and D to determine which has the closer % to fulfilling Building 1's requirements (trivial enough), then assigning workers in a 1:1 ratio (for now) to collect those resources.
I'm stuck on the assignment part though. I can't think of a logic pattern to find out what resource is needed, then find what job produces that, then assign a worker to it.
>>
Where you guys learned to code?
>>
>>52924060
School. Hobbies. General boredom. Literally pick up a book and see if it clicks.
>>52924031
Then enjoy that ridiculously tedious road to get the proper pills to get your life in order. Hopefully you only need to start on Zoloft 50mg and that does it for you. Because getting on and off pills takes two months of time, then more appointments to get different pills so you can start over. It's a bitch.
>>
File: 1451431535166.jpg (35 KB, 561x365) Image search: [iqdb] [SauceNao] [Google]
1451431535166.jpg
35 KB, 561x365
>>52923646
Reminds me of
>>
should I kill myself, dpt?
>>
>>52924118
Only if you want to do that. Are you incapable of learning something new and finding meaning to life?
>>
>>52924058
Make a datastructure that maps resources to the job that produces them, like a Dictionary<Resource, Job> for example?
>>
>>52924136
>meaning to life

Life has no meaning faggot
>>
>>52924136
no, but my material and social conditions make it difficult. also, I've wasted, like, 10 years of my life being a dumb fuck

anyway, I was expeting an automatic "yes"
>>
Threadly reminder that you should not refer to the act of programming as coding. It is improper and makes you look like a 16 year old

You are a programmer, not a coder

Software Alchemist is GOAT
Developer is okay
Magician is okay
Software Magus is okay
Software Engineer is okay
Software Architect is okay
Code Guru is questionable

Archmage is reserved for only the most senior of programmers

Writing in HTML and CSS is not programming, therefore it should be referred to as designing
>>
File: 1435878721912.gif (842 KB, 280x224) Image search: [iqdb] [SauceNao] [Google]
1435878721912.gif
842 KB, 280x224
>>52924058
None of this makes sense. Is this even proper English?
Are you trying to program a video game?
Are you trying to program a work/resource simulator?
Are you trying to program an optimization algorithm for work/load balance?

What the flying fuck are you even trying to do?

In any case, parallel processing is tricky. Each resource, worker, building should be a class, and each collection too. Also you will need external thread manager classes if you want proper OOP. But since you write like an Indian

>It is determined Building 1 needs to be built.

I can't give any further advice.
>>
>>52924137
Is there any way to create such a thing without having to duplicate the Job/Resource dictionary data?
The dictionaries in question also hold information such as number of filled jobs, current rate of resource collection, etc. and are updated from different spots.
>>
>>52922747
i would increment before printf.
>>
>>52922630
>while(0x4)

LMAOOOOOO
>>
>>52924183
Do you not know how to understand variable names or something?
All resources share the same characteristics, each one being its own class (of which there would then be 50) is retarded.
Same for workers.
Same for buildings.
This isn't multi-threaded, it's a basic AI on a tick-based system, so fucking around with threads is totally unnecessary.

Why the building has to be built is irrelevant to the question.
>>
>>52924174
>>52924174
Well I'm not a therapist or anything, so I guess if you want to kill yourself, go right ahead.
>>
>>52923209
>java

:^) nice meme brother
>>
I'm trying to roughly calculate the minimal requirements for something I'm writing but can't be bothered to actually benchmark the thing on a bunch of different platforms. I know there are many different hardware architectures which change how many cycles a given sequence of instructions typically takes but on average, assuming no user-installed programs running in the background and no automatic updating, how many cycles does Windows 7/8/10 consume passively? Is it a significant number? Am I asking the wrong questions?
>>
>>52924176
How about Technowitch?
>>
>>52921727
this
>>
>>52924194
>Is there any way to create such a thing without having to duplicate the Job/Resource dictionary data?
You would want to use references to the jobs and resources, so they wouldn't really be duplicates. I can't really speak to your specific case, that's just the first thing that came to mind. But if the Resource->Job required mapping stays constant (i.e. you don't suddenly get a different resource from a job), then this might be a pretty simple and elegant way of doing it.
>>
>>52924382
I don't know why I didn't think to use references. I think this'll put me on the right way, thanks
>>
How do I get better at programming?

I've gotten to the point where all the shit on those ideas pictures are either way too easy for me, and so I learn nothing, or are so difficult I don't even know where to start.
>>
>>52921600

?
average: ;fastcall ecx,edx
push ebp
mov ebp,esp

mov [esp-04h],ecx
mov [esp-08h],edx

fild dword[esp-04h]
fild dword[esp-08h]
faddp

mov dword[esp-04h],2
fild dword[esp-04h]
fdivp
fist dword[esp-04h]

mov eax,[esp-04h]

mov esp,ebp
pop ebp
ret


All of your problems are fixed in assembly. No more ambiguity. Join us.
>>
>>52924117
'x++ += x++ + ++x' and the goes-to-very-quickly operator both came out of the same codeshare. slides-to was a subsequent meme.

I was there for it all, anon. I've seen things most programmers can't even dream of.
>>
>>52924452
mate I'm the man who wrote the slides to operator, watch your tongue
>>
I am learning programming and I want to make a relatively video game. The premise is basically Civilization meets Tamagachi meets a little Dwarf Fortress. (AI civilizations interacting in a virtual world with limited user interaction and lots of detailed information to read that runs 24/7.) I then want to put this on a raspberry pi with a touch screen, battery, and some sensors.

I want to learn using a language like Scheme/Haskell because I own some books on them and I really like what people say about them, but if that is dumb I would like some suggestions on what I should use.

I am in University and I am currently taking the CSIII class for an idea of my experience level, my biggest project was 800 lines in Java and I want practice working on something bigger.
>>
>>52924513
*relatively large
>>
>>52924292
> Am I asking the wrong questions?
Yup.

Unless you have something significant running in the background, background CPU usage is likely to be less than 1%.

Also, when it comes to "cycles", accessing memory might take one cycle (if the memory is in the cache), up to a few dozen cycles (if the memory isn't in the cache, depends upon whether it has to wait for an existing transfer to complete), or millions of cycles (if the memory is paged/swapped out and has to be read from disk).

IOW, the only remotely accurate way to gauge performance is to actually measure it.
>>
>>52924510
How does it feel to be the world's worst shitgrammer?
Your puny "operator" has nothing on the apocalypses-to operator!
int main((void)void) {
for(int i *********[[[
****]]]]
***]]]
**]]
*]
0] //i apocalypses to 0 very quickly
) {
printf("%i", i);
}
}
>>
>>52924513
C++/Lua

Scheme/Haskell will use paradigms your probably not familiar with
>>
>>52924544
This was very helpful. Thank you.
>>
>>52924549
Your operator is potent I must say, but it is simply not meme material.
>>
>>52922697
>Not using language features.
>>
>>52924563
Paradigms like what?

I know some things, I read about 30% of Learn you a Haskell for great good and some scheme shit.
>>
>>52924432
You program your own ideas or you google the stuff you don't know? But if you have to ask then I have my doubts as to your ability to self-teach.
>>
>>52922630
That braces, OMG WHY.
>>
>>52921519
I don't get your picture.
Also, you're a faggot.
>>
>>52922630
>uses both %i and %d
Why?
>>
>>52924636
Not that guy but I put braces on the same column because my autism forces me to.
>>
>>52922937
> What is this crap.
Withness me!
auto func = [] { return ":P"; };
>>
>>52922630
if(i == 0)
{
break;
}
>>
I'm learning python, and I got a project which requires me to do google image search with an image. Is there any way to do this ? I've searched google but it's not really helpful.
>>
>>52921519
holy shit bernie got 60% and trump only got 35%? why even have the election trump's gonna lose
>>
>>52922630
Tried for a serious attempt since I'm still learning C.
#include <stdio.h>

int main( int argc, char **argv)
{
int i = 1;
for(; i < 6; ++i)
printf("%d\n",i);
for(; i > 0; --i)
printf("%d\n",i);
}
>>
>>52924723
you're retarded
>>
>>52924717
What exactly are you trying to do? Search for images based on text, images based on images, or are you simply trying to utilize google image search in your own program? If the latter take a look at https://developers.google.com/web-search/docs/

>>52924432
>so difficult I don't even know where to start.
These are the problems you NEED to do to get better. Of course you don't know where to start, you haven't tried figuring it out. Pick a project that looks fun then figure out how to go about doing it. If you need to be pushed in the right direction just ask here, but try figuring it out on your own first.
>>
>>52924717
https://developers.google.com/custom-search/json-api/v1/reference/cse/list#try-it
>>
>>52924762
Compact your shit senpai.
main() {
for(int i = 1; i < 6; ++i) printf("%d\n", i);
for(; i > -1; --i) printf("%d\n", i);
}


When using gcc, printf is an implied expansion so you don't need to include stdio.h just for it. Also, both the 'int' and the arguments to main are unnecessary.

You can golf this even more if you wanted to:

main()
{for(int i = 1; ++i < 5;) printf("%i\n", i);
for(;i-->0;) printf("%i\n", i);}
>>
>>52924848
>This is good programming sempai.
Don't listen to this brat. Write proper readable code.
>>
>>52924848
Won't compile with my compiler.
>>
>>52924848
Unless C is shit, the i is out of scope of the second loop.
>>
>>52924563
Why lua?
>>
I have this quick app that i wanna make for android and iOS, any useful tools for multiplataform development? Free, preferably.

Tried QT but i don't really like it.
>>
>>52924891
>multiplataform development?
HTML 5 >>>/wdg/
>>
>>52924870
>>52924876
Shit, you're right the i would be out of scope.
So that needs to be fixed.

I think it's also possible that some compilers won't like the "-->" so that should probably be fixed too.

If I remember correctly implied arguments still work in C03, so this should work.

main(i) {
for(i = 1;++i < 6;) printf("%i\n", i);
for(;--i > 0;) printf("%i\n", i);
}
>>
>>52924848
When initializing the variable inside the for loop, it goes out of scope as soon as it ends
for(int i=1; 1<6; i++) {}

printf("%d",i); //error
>>
>>52924891
Write it in c++ and then cross-compile.
>>
>>52924432
I'd recommend starting here, start with the really difficult stuff that even university graduates can learn from, you'll be a programming God in no time https://www.youtube.com/watch?v=Er6R5R06Q8I
>>
>>52924915
>>52924920
Won't compile with my compiler.
>>
>>52924934
Meme yourself.
>>
>>52924946
You sure? What's the error?
>>
File: oh god help.png (161 KB, 1052x690) Image search: [iqdb] [SauceNao] [Google]
oh god help.png
161 KB, 1052x690
>>52924934
>mfw
>>
>>52921639
fuck off tripfag
>>
>>52924848
You can't code for shit. good job.
>>
>>52924915
Just actually compiled this to see if it works. It does, but it starts at 2 due to an oversight.
Here's the corrected code:
main(i) {
for(--i; ++i < 6;) printf("%i\n", i);
for(; --i > 0;) printf("%i\n", i);
}
>>
>>52924796
In short, the program i'm doing scrapes image from imgur, and then determine what if it's an image of cats (or porn, or whatever) using keywords found in the google result page when you search that particular image.
To be honnest, i just need a way to code an image search in python, and i'll deal with the rest.
>>52924814
I'll look into that, thanks.
>>
>>52923322
it doesn't give the correct output for all signed ints
>>
>>52925022
Won't compile with my compiler.
>>
>>52924977
What face is that?
>>
>>52925022
int main(int i)
{
for(;i < 5; printf("%d\n", i++));
for(;i >= 0; printf("%d\n", i--));
}
>>
>>52925099
What compiler?
>>
When is it okay to use the var keyword in C#
>>
>>52925127
when ever you need it.
>>
>>52925127
A: When it's extremely explicit what the type will be, or
B: In a foreach loop.

A is usually only applicable when you're using the 'new' keyword in the declaration.
>>
>>52925116
gcc with correct options
>>
>>52925127
When it makes code more clear.
>>
>>52924723
35% is in relation to a whole bunch of republican candidates (even more candidates than the pic shows). 60% is only vs clinton. the poll doesn't show bernie vs trump.
>>
>>52925153
$ gcc -o test test.c
test.c:1:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
main(i) {
^
test.c: In function ‘main’:
test.c:1:1: warning: type of ‘i’ defaults to ‘int’ [-Wimplicit-int]
test.c:2:21: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
for(--i; ++i < 6;) printf("%i\n", i);
^
test.c:2:21: warning: incompatible implicit declaration of built-in function ‘printf’
test.c:2:21: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
test.c:3:18: warning: incompatible implicit declaration of built-in function ‘printf’
for(; --i > 0;) printf("%i\n", i);
^
test.c:3:18: note: include ‘<stdio.h>’ or provide a declaration of ‘printf
$ ./test
1
2
3
4
5
5
4
3
2
1
$
>>
>>52924934
I wonder what a program written in accordance to these rules would actually look like
>>
In erlang, I'm trying to make a rock, paper scissors game that returns the score of the game like
game_score([{paper,scissors},{paper,paper},{scissors,rock}]) = -2
code:
result(paper, paper) -> draw;
result(paper, rock) -> win;
result(paper, scissors) -> lose;
result(rock, paper) -> lose;
result(rock,rock) -> draw;
result(rock, scissors) -> win;
result(scissors, paper) -> win;
result(scissors, rock) -> lose;
result(scissors, scissors) -> draw.

num_result(X,Y) -> res_to_num(result(X,Y)).
res_to_num(win) -> 1;
res_to_num(lose) -> -1;
res_to_num(draw) -> 0.

I don't quite get how I'm supposed to do multiple entries into the game score, any help?
game_score([{ , }]) -> num_result(X,Y).
>>
>>52925127
always
>>
>>52923808
it's a minimalist (lacking in features) freetard cross-platform framework hacked together by complete amateurs. it restricts you more than it helps and it hides implementations behind tightly coupled backends to keep the casual user from seeing through the bullshit.
>>
What the fuck is happening here?

gcc -O2 -ansi -g -Wall -o brainfuck brainfuck.c
brainfuck.c: In function 'execute_cmd':
brainfuck.c:89:23: warning: value computed is not used [-Wunused-value]
case INCREMENT_PTR: *ptr++; break;
^
brainfuck.c:90:23: warning: value computed is not used [-Wunused-value]
case DECREMENT_PTR: *ptr--; break;
^
>>
>>52925172
Which code are you compiling, I gonna show you the error that gcc is reporting.
>>
>>52925221
Maybe the priority is not what you think.
>>
>>52925278
main(i) {
for(--i; ++i < 6;) printf("%i\n", i);
for(; --i > 0;) printf("%i\n", i);
}
>>
>>52925221
Maybe you never used ptr.
>>
>>52925177
r8 me anons
#Jet fuel can't melt steel beams, Donald Trump, Bernie Sanders, confession bear, the cake is a lie, can i haz cheesburger, unpopular opinion puffin, jet fuel can't melt steel beams Jet fuel can't melt steel beams, Donald Trump, Bernie Sanders, confession bear, the cake is a lie, can i haz cheesburger, unpopular opinion puffin, jet fuel can't melt steel beamsJet fuel can't melt steel beams, Donald Trump, Bernie Sanders, confession bear, the cake is a lie, can i haz cheesburger, unpopular opinion puffin, jet fuel can't melt steel beamsJet fuel can't melt steel beams, Donald Trump, Bernie Sanders, confession bear, the cake is a lie, can i haz cheesburger, unpopular opinion puffin, jet fuel can't melt steel beamsJet fuel can't melt steel beams
def takeinput():
if 1 > 0:
if 2 > 0:
if 3 > 0:
if 4 > 0:
if 5 > 0:
return input()
def isafag(x):
if 2 > 1:
if 3 > 1:
if 4 > 1:
if 5 > 1:
if 6 > 1:
print(x, 'is a fag')
if 9 > 2:
if 10 > 2:
if 11 > 2:
if 12 > 2:
if 14 > 2:
name = takeinput()
if 20 > 19:
if 20 == 20:
if 2 == 2:
if 4 > -1:
if 6 > 10:
print(isafag(name))
#Hitler did nothing wrong
>>
I wrote a small timetable app for an Android class a few years ago and I kinda want to get back into it. I haven't programmed in a pretty long time and I've forgotten most about Android.

Can anyone recommend a book or quick intermediate tutorial on it? People are using Android Studio these days right?
>>
>>52925221
This is what is happening *(p++)
Remove the asterisk.
>>
>>52925315
~/tmp$ gcc -std=c89 -Wall -Wextra -Werror -Wfatal-errors -pedantic -o test test.c 
test.c:1:1: error: return type defaults to ‘int’ [-Werror=return-type]
main(i) {
^
compilation terminated due to -Wfatal-errors.
cc1: all warnings being treated as errors
>>
>>52925349
More readable than this shit >>52922630. 10/10 for having the commitment to actually write 20 unique ifs
>>
>>52925366
Are you going to add this to the Linux kernel?
>>
>>52925221
>-O2
disgusting
>>
>>52925366
>
-Werror


Do I look like a fucking NASA developer?
>>
>>52925221
>gcc
disgusting
>>
>>52923229
>implying >>52923066 would benefit from TCO
Back to the designated street Pajeet.
>>
>>52925606
It would if he hadn't been stupid enough to leave out the else'es. I glance over someones code, assume it's done the correct way and suddenly I'm shitting in the streets?
>>
>>52922227
if you're such a good programmer then why didn't you hack 4chan and get quintuple repeating digits in your post number?
>>
File: 8TGbAgbEc.jpg (76 KB, 327x327) Image search: [iqdb] [SauceNao] [Google]
8TGbAgbEc.jpg
76 KB, 327x327
Simple question for you guys. I'm a beginner in programming. I know a bit about what is a "if-function", how to write hello world, etc. so basically nothing. But I know how to create the graphical UI-assets and how to structure a software/app. I thought about making a very simple app just to get into it but I want to be able to use it on my phone. Which programming language/tool should I use? Swift or is developing for android easier?
>>
>>52925722
Honestly the easiest choice would be to make a website. Check out >>>/g/wdg/
>>
How is -1 stored in binary as a 16-bit integer? How is it physically stored in memory?

I thought it was the same as 255, except that the SF (or Sign Flag) was set.

For example, my teacher told me to convert the following signed value to binary:

CFA2

I put:
1100 1111 1010 0010 (this was marked wrong)

I get it, the most significant bit is set.
It's a signed value so the signed flag is set.
So therefor, inorder to find the decimal value, I need to find the twos complement. But he asked for binary.
Doesn't this mean that literally all I have to do is convert it to binary and then I'm finished?
What the fuck is the point of twos complement if I'd have to do it for the BINARY value.
>>
>>52925769
Already know how to build websites but only the HTML/CSS side of it. No javascript. But thanks, gonna check it out as well.
>>
WHO EMACS HERE?

>>52925782
If the processor uses two's complement, then -1 is stored as "1111111111111111"

Not sure about the second part, but if a value is already signed, then the teacher probably meant to say "positive CFA2", in which you would do the same thing as you have done, but put an extra zero for the most significant bit, So "01100111110100010". It's hard to come up with a better answer without context.
>>
>>52925782
>How is -1 stored in binary as a n-bit integer?
0b1111... for n bits.
>>
>>52925871
>WHO EMACS HERE?
EMACS REPRESENT
>>
>>52925782
>How is -1 stored in binary as a 16-bit integer? How is it physically stored in memory?
0b1111 1111 1111 1111
>I thought it was the same as 255, except that the SF (or Sign Flag) was set.
That would only be true for an 8 bit integer.

>CFA2
>1100 1111 1010 0010 (this was marked wrong)
Yeah, I don't know what the fuck your teacher is up to.
>>
>tfw making an rpg in java
it's actually really fun. going to start working on status effects like "bleed", "poison", "paralyze" etc now. should i have one huge 'Combat' class or should it be a package?
>>
Reminder that the best way to average two ints in C is patented.
Copyright is cancer.
>>
>>52925967
>Living in a country that has software patents
Stupid burgerclap
>>
>>52925967
>Copyright is cancer
Copyright is capitalist monopolies weapon.
>>
>>52925951
I don't know about a huge "Combat" class. It may make more sense to have one huge "WorldState" class, which would have info for current combat in progress, but also contains information about how far along you are in the storyline, what entities are currently on-screen, etc.
>>
>>52925998
how i was planning on it right now was just to have like 14 different "chapters", and it just reads from a text file information about your party and what chapter you're in and it initializes your hero objects to what the save file specifies and it loads what chapter the save file says. so it'd be like having 10 save points for the entire game. it's purely text based btw
>>
>>52925928
Ah right thank you, 8-bit.

How the hell do I prove this to him? He explained that it was a "trick question" to see who really read the text book.

He took my answer and did this:
1100 1111 1010 0010
0011 0000 0101 1101
0011 0000 0101 1110
^ saying that's how (signed) CFA2 is stored.

I replied with saying, "so the SF is completely separate?" "Yes."
"and the maximum value for an 8bit unsigned int is 255?" "Yes."
"Then what would happen if the signed flag were set? Would it not be -255?"
"The signed flag cannot be set for an unsigned value."

He then went on a huge rant about how were novice programmers who are used to Java and C++ and can see why were confused.
I'm new to this shit so I couldn't come up with a better argument.
>>
>>52926027
Your teacher is a moron.
>>
>>52926027
>^ saying that's how (signed) CFA2 is stored.
Oh, I get it now.

A more clear question would have been "Represent, in 2's complement, negative CFA2".

Your teacher probably doesn't know what he's talking about, considering that he thinks "signed" is a general term for "negative". A signed number can also be positive, and this question is nonsense.
>>
>>52926027
>saying that's how (signed) CFA2 is stored
But any number can be signed. It's just how you decide to interpret it.
CFA2 is stored as CFA2, because that is what it is. It's up to you whether you want to interpret it as 12382 or -12382.
>"so the SF is completely separate?" "Yes."
It's not though. It's part of the number's representation, and is required as part of the calculation (for overflow and stuff).

I'm just going to say that your teacher is fucking stupid.
>>
>>52921893
>
if ((a < 0) != (b < 0)) {

Use
((a^b)<0)
instead.
Compiler is probably going to optimize it anyway though.
>>
>>52925967

Copyright and patents are not the same thing, and the patent is for the use of it in hardware, not the algorithm in general, or its implementation in software.
>>
>>52925967
it's not; the meme you're spewing has nothing to do with averaging 2 ints
>>
>>52926096
>It's not though.
I was just asking him if it were stored separately. (NOT in the binary value).
I was basically double checking that the sign flag is in fact NOT the most significant bit, and is stored in a different... register?

I plan on making an assembly program and storing the values that he asked about manually, then dumping the registers to show him, if he doesn't come to his senses over the weekend.
>>
File: Selection_095.png (45 KB, 1915x1079) Image search: [iqdb] [SauceNao] [Google]
Selection_095.png
45 KB, 1915x1079
>>52925871
t. lispmachine
>>
>>52926114
>Compiler is probably going to optimize it anyway though.
Actually it's not, at least gcc isn't.
Clang seems to do the job though.

http://gcc.godbolt.org/#{%22version%22%3A3%2C%22filterAsm%22%3A{%22labels%22%3Atrue%2C%22directives%22%3Atrue%2C%22commentOnly%22%3Atrue%2C%22intel%22%3Atrue%2C%22colouriseAsm%22%3Atrue}%2C%22compilers%22%3A[{%22sourcez%22%3A%22EYexBsAIQBxkDOBLAdgcwPrLSgjAClQBdIBDAGkmMmAEpIBvAKEkgCcBTIgVzZUnykAPAAZ6AQgC8A4KNoBuJgF8mTUBGhxEqTNhQAmQihIUqxmvWatOPPgNIA9OpCGQRipUAA%3D%3D%22%2C%22compiler%22%3A%22g530%22%2C%22options%22%3A%22-O3%22}]}
>>
>>52926114
xor-ing signed numbers is retarded
>>
>>52926201
Nice fucking URL.
>>
>>52926204
It's a well defined operation, how is it retarded?
>>
>>52926128
>not the algorithm in general, or its implementation in software
good, because it doesn't apply to this problem anyway
>>
>>52926211
The shortened URL was detected as spam, and I wouldn't want to force anyone to have Google track their browsing journey.
>>
>>52926215
By making me break out the notepad and pen just to read your shitty if statement.
>>
>>52926164
What color theme is that?

I really like bbatsov's solarized dark, but always looking around.
>>
>>52926162
>I was just asking him if it were stored separately. (NOT in the binary value).
It is stored in the binary value. For twos compliment to work, or even make any sense, the most significant bit HAS to be the sign bit.
>>
>>52926241
farmhouse-dark.
I used solarized-dark for awhile but farmhouse has a more vibrant color scheme, which I think looks better.
>>
>>52926231
XOR is literally made for this - if the signs differ then the sign bit of the resulting number will be set and the number therefore negative.
>>
NEW THREAD WHEN???
>>
>>52926270
Later. It's not needed yet.
>>
File: Selection_096.png (61 KB, 1920x1079) Image search: [iqdb] [SauceNao] [Google]
Selection_096.png
61 KB, 1920x1079
>>52926261
>>52926241
Here's some C code, showing the yellow and white in more detail.
>>
>>52926215
it's well defined wrt representation, not with respect to value; ie. it can generate a trap representation
>>
>>52926285
>not with respect to value; ie. it can generate a trap representation
Please elaborate.
>>
>>52926264
>the sign bit of the resulting number will be set
ok with this
>and the number therefore negative
or a trap, and you can't compare it to anything
>>
>>52926304
see >>52926305
>>
>>52926264
It's easy to go from "I need to check if the signs differ" to "let's use XOR".
It's hard to go from "this chucklefuck is XOR-ing these ints for some fucking reason" to any sort of conclusion.
Basically it's bad for readability, at least in my opinion. It's at least worth a comment.
>>
>>52926305
>>52926285
I don't see anything about trap representations here.
>>
>>52926342
>It's at least worth a comment.
Yeah I agree. It just saves you one instruction anyway, the branch itself is going to take much longer.

>>52926327
>>52926305
I don't think trap representations have any relevancy in practice - are there any recently produced chips that have them?
>>
File: 310.png (6 KB, 441x175) Image search: [iqdb] [SauceNao] [Google]
310.png
6 KB, 441x175
>>52926273
Isn't 310 the limit?
>>
File: 1454595703475.jpg (401 KB, 1280x720) Image search: [iqdb] [SauceNao] [Google]
1454595703475.jpg
401 KB, 1280x720
>>52926201
GCC once again proven to be deprecated.
Clang masterrace.
>>
>>52926404
Just because we're past the bump limit, it doesn't mean we need a new thread.
We're only on page 4.
>>
>>52926413
Clang is shit with OpenMP though
>>
>>52926419
What is the new rule?
>>
>>52926392
>relevancy in practice
if we restrict the discussion to practice we can just simplify C a lot down to 8 bit chars and 2's complement
>>
Jesus, here is a new thread, because you kept fucking complaining:

>>52926461
>>52926461
>>52926461
>>
>>52926386
look at integer type representations
>>
>>52926435
The rule is you don't make a new thread unless you have something to talk about and the old thread is falling off the front pages.
>>
I've just started programming, and am using java as my first language. I'm trying to make an example program for learning purposes that will take a day of the week, and check if it's a weekday or weekend; simple stuff. I've been doing it with a load of if/else if statements, but have been told there's a way to do it in 1-3 statements. How would i go about doing this?
Thread replies: 341
Thread images: 28
Thread DB ID: 515984



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

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

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 shown content originated from that site. This means that 4Archive shows their content, archived. If you need information for a Poster - contact them.
If a post contains personal/copyrighted/illegal content, then use the post's [Report] link! If a post is not removed within 24h contact me at [email protected] with the post's information.