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

File: dpt.jpg (50KB, 531x796px) Image search: [Google]
dpt.jpg
50KB, 531x796px
OLD THREAD >>57679595

What are you working on, /g/?
>>
File: Haskell Memory.png (21KB, 422x340px) Image search: [Google]
Haskell Memory.png
21KB, 422x340px
>>
>>57679622
>>57679788
>>57679800
>>57679866
>>57679899
>>57679922
>>57679944
>>57680044
>>57680366
>>57680511
>>57680966
>>57680999
>>57681544
>>57681655
>>57681811
>>57682599
>>57682755
>>57683077
>>57683111
>>57683244
>>57683299
>>57683566
>>57683599
>>57683688
>>57683711
>>57683755
>>57683833
>>57683855
checked (the old thread) :^)

var elements = document.getElementsByClassName('postContainer');
var com = document.getElementsByName('com');
var str = com[0].value;


for(var i=0; i < elements.length; i++) {
if(elements[i].getAttribute('id')[elements[i].getAttribute('id').length-1] == elements[i].getAttribute('id')[elements[i].getAttribute('id').length-2])
str += '>>' + elements[i].getAttribute('id').substring(2) + '\n';

}
str += 'checked :^)';
console.log(str);
com[0].value = str;
>>
Thanks for using an anime image as a reminder I'm not the only social misfit on earth.
>>
>>57684126
>1 (You)
Thank (You)
>>
>>57684119
>1^6
>>
>>57684131
But anon, you are.
>>
>>57684144
:^)
an old mistake

here's a better version
x = alloca $ \ptr -> 
do str <- readLn :: IO Word8
ptr `poke` str

threadDelay (1 * 10^6)

str' <- peek ptr
print str'
>>
>>57684126
Delet this
>>
Please give me a good rebuttal for when someone tells me
>C is shit
>>
>>57684195
>h-hahaha autist y-you're just mad
you're welcome
>>
>>57684195
It's not wrong. Other imperative languages are shittier.
>>
>>57684092
But can you set up a floating point with a user defined precision
>>
>>57684195
It is shit though, but one of the best languages to learn proper programming.

Just read 'learn c the hard way' - that guy explains it breddy gewd
>>
>>57684195
"You're right, I'm just too stupid to learn more complicated languages."
>>
>>57684240
Can you please give me the exact dual floating point representation for 0.1dec? Thanks.
>>
>>57684252
This one's good
>>
>>57684240
Of course.
That's what float16, float32, float64 are for.
>>
File: bodyjuice.webm (3MB, 1024x576px) Image search: [Google]
bodyjuice.webm
3MB, 1024x576px
/dpt/-chan, daisuki~

Ask your much beloved programming literate anything (IAMA)

>>57684195
https://www.youtube.com/watch?v=MShbP3OpASA&t=20m45s
You are welcome.

>>57684107
Thank you for using an anime image.
>>
interface Bank {
double getBalance();
void addBalance(double amount) throws Exception;
void removeBalance(double amount) throws Exception;
}
static void removeBalanceFromAllBanks(double amount, Bank[] banks) throws Exception {
for (Bank bank : banks) {
double b = bank.getBalance();
if (b > amount) b = amount;
try {
bank.removeBalance(b);
} catch (Exception e) {
// wtf to do here?
}
amount -= b;
}
}


So lets say you have a list of banks, each with some money in them.
You want to remove X amount of money from the collection of banks. It doesn't matter how much from which bank, as long as you get X amount.
The problem is, addBalance() and removeBalance() can fail, so you can end up removing more than zero and less than X which is bad. You want to either remove X or zero.
Above is pseudocode of the problem to make it clearer of what i'm trying to do.

Any ideas on how to solve this?
>>
>>57684314
Monad transformers
>>
>>57684314
what are you trying to solve exactly?

You have to decide what you want to happen if there's not enough money in the bank. That's not a software problem, that's deciding how you want your program to behave in the first place.

I would imagine the most logical thing to do would be to check if every bank has enough money before you remove any money, and if one of them doesn't then don't remove any money from any of them and let the whole method fail.
>>
>>57684314
Don't use double to calculate money.
>>
https://hackernoon.com/how-it-feels-to-learn-javascript-in-2016-d3a717dd577f#.bnuot8sug

^ This article essentially convinced me to never touch Javascript or any of the web stuff. I'll wait for it to crash and burn before I dip my toes in.
>>
>>57684314
>Java homeworks
Anyway, use break when amount reaches 0 and put "amount -= b" in the try statement so it's not executed when removeBalance throws.
>>
>>57684305
That's very long, can you tell me what this talk is about?
>>
>>57684389
watch at 20m45s
>>
>>57684374
JavaScript isn't going anywhere. Everyone knows it's shit. But there's a lot of demand for web shit, so people put up with it.
>>
>>57684283
Kek
>>
>>57684314
>>57684371
This is very important, doubles can fuck up in some really weird ways. You can store dollars and cents separately as long.
>>
>>57684364
It is guaranteed that the sum of balances of the banks is less than the amount required.
The issue is that removing money can fail even if the bank has the money required (due to some internal fuckup).

>>57684371
>>57684419
Than imagine it as an integer. Same problem.

>>57684380
Not a homework. I don't even have "banks" in the project. The code is just there to explain better what the problem is.
>>
>>57684405
Thanks. I might actually watch the whole talk at some time, looks nice.
>>
>>57684456
>It is guaranteed that the sum of balances of the banks is less than the amount required.
I mean the opposite. Sum of balances in the banks is MORE than the amount required.
>>
>>57684456
it's totally up to you how you handle that mess.

If it was me I'd return an object that says how much money was withdrawn and if there were any failures. Let the code that calls the method handle that object how it likes then.
>>
I'm learning ruby after using python because it seemed better and boy was I right. It seems to have much more than python ever could too.
>>
I was curious about the fast inverse square root function
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;

x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // what do this
i = 0x5f3759df - ( i >> 1 );
y = * ( float * ) &i; // and this do?
y = y * ( threehalfs - ( x2 * y * y ) );
// y = y * ( threehalfs - ( x2 * y * y ) );
return y;
}
>>
I'm working a project and want to apply tests.

I have created two tests:

@Test
public void testOne() {
doSomething(object);
Assert.assertSomething(object);
}

@Test(expectedException = myException.class)
public void testTwo() {
doThrow(new myException()).when(mockedClass).doSomething(any(Object.class));
doSomething(object);
}


How can I make sure only testTwo throws exception when calling DoSomething()? Regardless of in what order the two tests are called?
>>
>>57684374
I chuckled at the funny in that article.
>>
>>57684498
Mind sharing why?
>>
>>57684456
>Than imagine it as an integer. Same problem.
What are you talking about? The reason doubles can fuck up is because of precision issues. Comparing two doubles is not trivial at all. This things don't happen with ints/longs.
>>
>>57684500
Ok
>>
>>57684500
So? If you're looking for explanations there is a nice wikipedia article for it
>>
>>57684521
Did you see the comments in the code?
I was asking about these two lines and how they work
i  = * ( long * ) &y;
y = * ( float * ) &i;
>>
>>57684559
magnets
>>
>>57684559
reinterpret bits as long/float respectively. it's undefined behavior
>>
>>57684496
That's just avoiding the problem not solving it. Eventually down the line you're going to have to handle it.
It's doubtful it even has a clean solution. You can attempt to add balance back to previous banks if one of the banks fucks up, but then adding the balance back can fail too.

>>57684517
Same problem with banks. I am aware of precision issues. The example uses double for simplicity.
>>
>>57684559
nerve gas
>>
>>57684587
Why not this?
i = (long)y;
y = (float)i;

Don't both cast y and i to long and float?
>>
>>57684592
>That's just avoiding the problem not solving it.
That IS how you solve it. It can;t be done cleanly by the very nature of the problem. You can't make it such that the bank cash withdrawal can be guaranteed not to fail, so ALL code making a withdrawal has to be able to handle a failure. Much like when you write code that calls a web service method, you must always be able to handle a complete failure of the method since the network can always fail. It's not something in your control.
>>
>>57684592
>The example users double for simplicity
Nice language you have there
>>
>>57684617
it's a cast by value. 123.0 and 123 are not the same in terms of their bit representation
>>
>>57684592
Ok, so your problem looks similar to transaction handling in RDBMS systems. You can try to keep a 'log' of transactions and use that in case of a failure.
Read up on how RDBMS handle this shit. Search for transactions, undo logging, redo logging, etc
>>
>>57684617
>Don't both cast y and i to long and float?

Yes. That's not what the first one is doing lmao. The first one casts the pointer to the memory representation of a float to a long and back, allowing you to perform operations you wouldn't normally be able. Basically a compiler trick. The second casts the actual value.
>>
>>57684195
That's the entire point. It's portable assembly.
>>
>>57684587
But it's not undefined behaviour. He's just type casting a memory address to another memory address type.
>>
>>57684708
ever heard about strict aliasing?
>>
You have roughly 3.2 milliseconds to answer "Why aren't you releasing TRUE FOSS under the Do What The Fuck You Want To Public License"
        DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.
>>
>>57684754
Because I'm releasing it in the public domain.
>>
>>57684723
Honestly didn't know about that.
>>
>>57684754
Because I do what the fuck I want to do.
>>
>>57684754
Because I release it under the Thelemic license.
Do what thou wilt shall be the whole of the License.
>>
>>57684754
What if I want to change it without also changing the name?
>>
>>57684754
Because i'm too insecure about my sexuality to let anyone use my hard work without so much as a credit mention.
>>
>>57684790
Ego centered apes should kys
>>
>>57684767
you can do it with memcpy tho

http://stackoverflow.com/questions/24405129/how-to-implement-fast-inverse-sqrt-without-undefined-behavior
http://stackoverflow.com/questions/20762952/most-efficient-standard-compliant-way-of-reinterpreting-int-as-float
>>
File: ?.png (7KB, 120x120px) Image search: [Google]
?.png
7KB, 120x120px
post the last code you wrote

post a screen shot if you want
>>
File: 4.png (343KB, 494x596px) Image search: [Google]
4.png
343KB, 494x596px
>>57684126
Had a go at making that script in a non-disgusting way.

var postNumbers = document.querySelectorAll('.desktop .postNum a:last-child'); 
var postNumbersArray = Array.from(postNumbers);

postNumbersArray.forEach(function(elem) {
var postNum = elem.text;
var checkEm = postNum[postNum.length - 1] === postNum[postNum.length - 2];

if(checkEm) {
console.log(">>" + postNum + " checked :^)");
}
});
>>
>>57684790
>100 LOC shithub "library"
>hard work
>>
>>57684820
print("Hello world!")

I got bored after that
>>
>>57684818
But if you have to copy bits, it won't be as fast.
>>
>>57684836
It was hard for me.
>>
File: code.png (394KB, 1268x1442px) Image search: [Google]
code.png
394KB, 1268x1442px
>>57684820
>>
>>57684827
There.
console.log(Array.from(document.querySelectorAll('.desktop .postNum a:last-child')).map(element => element.text).filter(id => id[id.length - 1] === id[id.length - 2]).map(id => ">>" + id).join("\n"));
>>
>>57684818
>>57684852
or with an union
>>
>>57684782
That part is only for the license. The conditions for software is just
You just DO WHAT THE FUCK YOU WANT TO.


Everything above that section is for the license itself.
>>
>>57684852
compilers are good at optimizing memcpy

movl    %edi, -4(%rsp)
movss -4(%rsp), %xmm0
ret


>>57684893
i think that's still UB
>>
>>57684910
Isn't it basically just the MIT licence?
>>
>>57684890
Bit disgustingly unreadable desu.
>>
I want to try GUI with Python. Should I use PyQt or PySide?
>>
File: code.png (46KB, 713x286px) Image search: [Google]
code.png
46KB, 713x286px
>>57684820
>>
>>57684925
>i think that's still UB
not since c99
>>
>>57684926
Nah. The MIT license requires you to distribute the copy of the license if you're going to distribute the code.

http://choosealicense.com/licenses/
>>
>>57684971
Fucking jews
>>
>>57684947
is this a gtk application?
>>
>>57684754
Because it doesn't have that warranty bit
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
>>
>>57685031
yeah
>>
>>57685063
>in the modern world you can just add "not our fault.txt" and be instantly absolved of responsibility
>>
>>57684946
https://wiki.python.org/jython/SwingExamples
>>
>>57685063
>HUR DUH I KILLED WITH A CONDOM ILL COMPLAIN IN COURT

t. American
>>
>>57685063
Is there any sort of history of programmers releasing code into the public domain and then being sued for it?

I always wondered
>>
>>57684967
Possible undefined behavior, depending on implementation-defined properties of the types.
>>
>>57685116
you can't. You can remove the licence shit and redistribute it. But legally the original creator still own the copyright and can sue people who use the code outside the terms of the original licence, even if they didn't know it has a different licence.
>>
>>57685161
where in the standard you read that?
>>
>>57685166
How does that answer my question about warranty?
>>
mapM mapM [mapM, mapM] . mapM

>this is valid Haskell
>>
>>57685210
It doesn't. What was your question?
>>
i cant into visual C++
im getting a warning that some classes and stl containers "need to have dll-interfaces to be used by clients of myclass"

how i fix it?
is it enough to replace all public STL members with getters?
>>
>>57685222
Is there a history of programmers being forced to work on code by threat of court because of implied warranty?
>>
>>57685167
6.2.6p5 and any integer type other than unsigned char is permitted to have trap representations.
>>
>>57685215
foo = >> a <=< fucking >> :^) (^: *> do where && 


this is as valid and readable as haskel code
>>
>>57685250
Not sure. I think there's probably been cases where people have been sued over software bugs. Probably pretty rare though.
>>
>>57685263
that isn't valid at all
>>
>>57685250
usually the terms and conditions say it's "provided as is" with no warranty or anything
>>
>>57685293
heh, but it's as readable
>>
>>57685308
no it isnt
>>
>>57685328
>no it isnt
yes it is, haskell is not readable

you are such a typical haskell user
>>
Why is "echo" in php considered an language construct?
>>
>>57685374
>you can read? fucking haskell user
sorry anon
>>
>>57685374
Haskel is readable. But you need to actually know haskell.
>>
>>57685382
youre typical because your answers are passive aggressive bullshit

>no it isnt
>sorry anon

haskel is a fucking turd compared to scheme or lisp
>>
>>57685400
it's ok i'm not gonna hurt you
>>
>>57685378
don't question the php
>>
I want to hook some DirectX8 functions inside a process that already has some DirectX functions hooked. I'm injecting a dll into an already running process that already has hooks in place. They have already hooked the
Direct3DCreate8(D3D_SDK_VERSION);
function and redirected it to their own wrapper. Is it possible to get the addresses of some of the functions (i.e. Present, DrawIndexed, etc) without calling
Direct3DCreate8(D3D_SDK_VERSION);
and then
direct3D->CreateDevice(..)
to get the vTable?
>>
>>57685517
bls
>>
library IEEE;
use IEEE.Std_Logic_1164.all;

entity reg_4 is
port (
enable,rst_pot,rst,ckl1 : in std_logic ;
sel_pot : in std_logic_vector (9 downto 0);
out_pot : out std_logic_vector (9 downto 0)
)
;
end entity;

architecture behavior of reg_4 is

signal rst_p : std_logic := rst_pot or rst ;
begin

process (clk1, rst_p)
begin
if (rst_p = '1') then
out_pot <= "0000000000" ;
elsif ((rising_edge(clk1) and enable = '1')) then
out_pot <=
"0000000001" when sel_pot = "0000000001" else
"0000000011" when sel_pot = "0000000010" else
"0000000111" when sel_pot = "0000000100" else
"0000001111" when sel_pot = "0000001000" else
"0000011111" when sel_pot = "0000010000" else
"0000111111" when sel_pot = "0000100000" else
"0001111111" when sel_pot = "0001000000" else
"0011111111" when sel_pot = "0010000000" else
"0111111111" when sel_pot = "0100000000" else
"1111111111" when sel_pot = "1000000000" else
"0000000000";
end if;


end process;
end behavior ;

Can someone tell me what is the problem? It says Error (10500): VHDL syntax error at reg_4.vhd(24) near text "when"; expecting ";". But that doesn't make sense.
>>
>>57685252
wtf, just after that, the standard says

"The value of a structure or union object is never a trap representation, even though the value of a member of the structure or union object may be a trap representation."

stop spreading fake news, fucking shill.
>>
>>57685252
>>57685654
I told you guys C was a trap language
>>
I'm mapping the IPv4 reverse nameserver delegations down to every /24

1.in-addr.arpa ['tinnie.arin.net.', 'ns4.apnic.net.', 'ns3.apnic.net.', 'apnic.authdns.ripe.net.', 'ns2.lacnic.net.', 'apnic1.dnsnode.net.', 'ns1.apnic.net.']
5.1.in-addr.arpa ['ns4.odn.ne.jp.', 'ns2.odn.ne.jp.']
8.1.in-addr.arpa ['ns0.knet.cn.', 'ns1.knet.cn.']
9.1.in-addr.arpa ['ns2.tm.net.my.', 'ns1.tm.net.my.', 'ns3.tm.net.my.']
11.1.in-addr.arpa ['d.dns.kr.', 'g.dns.kr.', 'e.dns.kr.', 'b.dns.kr.', 'c.dns.kr.', 'f.dns.kr.']
16.1.in-addr.arpa ['b.dns.kr.', 'g.dns.kr.', 'c.dns.kr.', 'e.dns.kr.', 'f.dns.kr.', 'd.dns.kr.']
17.1.in-addr.arpa ['f.dns.kr.', 'd.dns.kr.', 'e.dns.kr.', 'b.dns.kr.', 'c.dns.kr.', 'g.dns.kr.']
18.1.in-addr.arpa ['b.dns.kr.', 'f.dns.kr.', 'd.dns.kr.', 'e.dns.kr.', 'g.dns.kr.', 'c.dns.kr.']
19.1.in-addr.arpa ['e.dns.kr.', 'g.dns.kr.', 'c.dns.kr.', 'f.dns.kr.', 'd.dns.kr.', 'b.dns.kr.']
22.1.in-addr.arpa ['ns3.tikona.in.', 'ns2.tikona.in.', 'ns1.tikona.in.']
23.1.in-addr.arpa ['ns1.tikona.in.', 'ns2.tikona.in.', 'ns3.tikona.in.']
34.1.in-addr.arpa ['ipdnsb2.hinet.net.', 'ipdnsb1.hinet.net.']
35.1.in-addr.arpa ['ipdnsb2.hinet.net.', 'ipdnsb1.hinet.net.']
36.1.in-addr.arpa ['ns6.netvigator.com.', 'ns4.netvigator.com.']
40.1.in-addr.arpa ['ns1.optusnet.com.au.', 'ns2.optusnet.com.au.']
41.1.in-addr.arpa ['ns1.optusnet.com.au.', 'ns2.optusnet.com.au.']
42.1.in-addr.arpa ['ns2.optusnet.com.au.', 'ns1.optusnet.com.au.']
43.1.in-addr.arpa ['ns2.optusnet.com.au.', 'ns1.optusnet.com.au.']
46.1.in-addr.arpa ['ns3.dtacnetwork.co.th.']
47.1.in-addr.arpa ['ns3.dtacnetwork.co.th.']
51.1.in-addr.arpa ['DNS.EDU.CN.', 'DNS2.EDU.CN.']
64.1.in-addr.arpa ['ns6.netvigator.com.', 'ns4.netvigator.com.']
65.1.in-addr.arpa ['ns4.netvigator.com.', 'ns6.netvigator.com.']
66.1.in-addr.arpa ['ns2.spmode.ne.jp.', 'ns1.spmode.ne.jp.']
67.1.in-addr.arpa ['ns2.spmode.ne.jp.', 'ns1.spmode.ne.jp.']
>>
>>57685881
ok
>>
>>57685654
Are you serious? Because if you're not, I don't have time for that.
>>
>>57684617
Those casts reinterpret the bits to mean something else.

Eg:
long int x=1; // x in hex is 0x00000001 using twos complement
float x1 = (float) x; // value is the same. But hex representation is 0x3f800000
float x2 = * (float * ) &x //value is 1.4E-45 but hex representation is the same

At least that's how I understand it. I'm sure other people are going to jump at the chance to prove me wrong

Read directly. It means to "get me the address of the variable, store it as the address of the pointer of a long, and then retrieve that address"
Although I'm assuming the compiler optimizes it heavily
>>
What are you guys listening to?
https://www.youtube.com/watch?v=cQTBkj6CGEU
>>
>>57686110
https://www.youtube.com/watch?v=J2LJYybgj-s
>>
>>57686155
I don't know if you're serious or trolling but I find this actually relaxing..
>>
Tell me about PHP. Is there any reason to use it for new projects?
>>
>>57686262
pure php probably not , but frameworks yes.
>>
>>57686272
>t. Web developer
>>
>>57686284
oh wow how did you deduce that? you must be some prodigy tier genius
>>
https://youtube.com/watch?v=dQw4w9WgXcQ
>>
>>57686110
>>57686305
Forgot to quote
>>
>>57686302
>>57686272
Web devs opinions don't count for anything.
Go back to your containment thread.
>>
>>57686337
go fuck yourself
>>
>>57686241
I'm serious senpai. I can concentrate much better when I listen to ASMR.
>>
>>57686104
>prove me wrong
sure.
>casts reinterpret the bits
Access with an expression whose type is different from the effective type of an object, excluding some special cases, leads to an undefined behavior. C doesn't prescribe semantics to that construct.
Type punning can lead to trap representations, in general. There is no strictly conforming program, that could interpret an arbitrary valid float object representation as a long value or backwards.
>store it
The result of a cast is a value, not an object. It doesn't have to be stored.
>>57685654
Hmm, I'll just say that the value of a union object is different from the value of its member object. They even must have different types.
>>
>>57686337
and neet opinions count ? nice one poorfag, go back to your waifu board
>>
>>57686376
Nice projecting, mate.
>>
>>57686409
k
>>
>>57686362
Count me in
>>
>>57685572
Are you using vhdl-2008?
>>
>>57686523
Yes. I rewrote the code, took all those "bla bla is bla bleg when bleg" out of of the if loop and assigned them to a internal signal and it worked. That part is just a decoder of sorts that goes from onehot to some pattern.
>>
>>57686365
>Access with an expression whose type is different from the effective type of an object, excluding some special cases, leads to an undefined behavior.
Are you denying that this isn't what happens when compiled with certain compilers?

I explained how it should work in theory when compiled correctly. Not that it's good behavior

>The result of a cast is a value, not an object. It doesn't have to be stored.
You're either storing it in a register or storing it in memory. Either way, this bit is what I meant by "optimized"
>>
Why isn't there better library support for IndexedFunctor, IndexedApplicative, and IndexedMonad?
>>
>>57686592
>I explained how it should work in theory when compiled correctly
It's undefined behaviour. There is no "compiled correctly".
>>
>>57684265
0x3fb999999999999a

#include "stdio.h"

union a {
unsigned long b;
double c;
};

int main(void) {
union a d;
d.c = 0.1;
printf("%llx\n", d.b);
return 0;
}
>>
>>57686607
http://hackage.haskell.org/package/category-extras-0.53.5/docs/Control-Monad-Indexed.html
>>
>>57686554
If you're using the 2008 syntax it should have worked. It's not legal in earlier versions.
>>
De fleste programmeringsspråk som skapes i dag er ikke basert på god forskning. Se på python, ruby og go som eksempler.
>>
>>57686621
Compiled correctly as intended by the author. Not the standard
>>
>>57686732
Then you're not using standard C, you're using some bizarro dialect that you just made up.
>>
>>57686725
le norsk meme
draeb dig selv idiot, drukn dig i en fjord
>>
>>57686732
NEVER rely on undefined behaviour, you retard.
The compiler is under absolutely no obligation to do anything, even if it's what you expect. The compiler can change its behaviour however it wants to, and it doesn't even have to be consistent.
If you've knowing put undefined behaviour in a program (unless you're trying to demonstrate it), you've completely failed as a programmer, and you should probably just quit now.

Also, violating strict aliasing is the sort of shit that breaks when optimisations are turned on.
>>
>>57686592
>what happens
Undefined behavior isn't restricted by its effects.
>certain compilers
... with certain flags (fno-strict-aliasing) on certain platforms. Just write it in assembly.
>it should work in theory
In theory, compilers should complain.
>You're either storing it in a register or storing it in memory.
Nope. Some values are removed from being represented on your computer by the standard: *&x is forced to be reduced to x.
>>57686628
how horrible!
>>
i-is it true that embedded and kernel programmers make below average salary?

Sucks for me, because i wanted to specialize in systems programming.

I am interested in a lot of areas of software development, and I'm looking to specialize in something to find a job.
In you guys' experience, what is the most high-paying "category" (e.g. backend development, databases, network programming, machine learning, graphics, etc) of software development for a person to specialize in?

I want to do stuff that interests me in my free time, but I need a well paying job doing any kind of programming.
>>
Writing my own shell in C for last Uni assignment of the semester. Got everything working now just need to add pipes
>>
>>57686753
> you're not using English if you pronounce it toMAYto. You have to pronounce it toMAHto

>>57686784
Tell that to John Carmack

I'm serious. He's the one that used it
>>
I'll try to avoid a segmentation fault (core dump) with my code by initializing a vector in my class to "myvec(0)" in the class default constructor. This is because a function in my class requires that the vector not be empty in order to work, however now a zero is being append to my vector, so instead of "1, 2, 3, 4" I get "0, 1, 2, 3, 4". How do I get rid of the zero?
>>
>>57686827
>He's the one that used it
It's attributed to him, but I don't think he was the one who actually wrote it.
Back then, strict aliasing wasn't something that was understood by many programmers and violating it was considered the norm.
It's something you might see in old-code, but that's no excuse for doing that shit now. Optimisers are now much more aggressive, and will optimise based on aliasing, and it can break your code. Compilers had to add things like -fno-strict-aliasing to accommodate old, broken code.
>>
>>57686827
>I'm gonna make up my own variant of English where 'crimpfriggle' means 'frog'
>why does nobody use my variant of English?? It's just as valid as Canadian English or Australian English!
>>
Am I doing it right, /g/?

typedef struct item {
item_index_t item;
} item_t;

typedef struct door {
item_index_t key;
bool locked;
} door_t;

typedef struct chest {
item_index_t content;
item_index_t key;
bool locked;
} chest_t;

typedef union object_info {
item_t item;
door_t door;
chest_t chest;
} object_info_t;

typedef enum object_type {
OBJECT_TYPE_ITEM,
OBJECT_TYPE_DOOR,
OBJECT_TYPE_CHEST,
} object_type_t;

typedef struct object {
object_type_t type;
object_info_t info;
} object_t;
>>
>>57686855
>kids these days don't know what unions are for
>>
>>57686855
>>57686925

yes

here is the haskell

data Object =
Item { item :: ItemIxT }
| Chest { content :: ItemIxT ,
key :: ItemIxT , locked :: Bool }
| Door { key :: ItemIxT , locked :: Bool }
>>
>>57686926
>>57686952
New code here >>57686925 I removed a stray apostrophe

pls tell me what a union is for
>>
>>57686952
>>
>>57686875
Right. But why are you still lecturing me about describing how a piece of code works you fag?

>>57686903
Just like Shakespeare used to do?
>>
>>57686960
It's a perfectly valid use of a union.
You've created a tagged union.

>>57686998
What's wrong?
>>
>>57687000
When you become the best writer in the history of the English language, then you can make up your own words.
>>
>>57686998
Is this better?

data Locked a = Locked { key :: ItemIxT, locked :: Bool, contents :: a }

data Object =
Item ItemIxT
| Chest (Locked ItemIxT)
| Door (Locked ())
>>
File: 5.png (395KB, 680x665px) Image search: [Google]
5.png
395KB, 680x665px
Why is web hosting so expensive?
>>
>tfw work won't let you use language features
>>
>>57687109
Social media networks paying hosting companies to artificially raise their prices, so rather than hosting their own websites most people will just use Facebook, Twitter, etc.
>>
>>57686794
I literally wrote it on https://repl.it/languages/c in 15 seconds.

#include <inttypes.h> /* uint64_t */
#include <stdio.h> /* printf() */

union double_to_uint64 {
double f64;
uint64_t u64;
};

int main(void)
{
union double_to_uint64 dti = { .f64 = 0.1 };
printf("0x%llx\n", dti.u64);
return 0;
}
>>
>>57687012
>>57687049
You can't easily write that in haskell at all.
Try to add a new type for classes with object/function/something else members and dynamic dispatch without changing your code.
>>
File: Octocat.png (35KB, 800x665px) Image search: [Google]
Octocat.png
35KB, 800x665px
post your github
>>
>>57687157
What are you on about?
I'm mimicking anon's code.

What is it that you want the code to do?
>>
>>57687164
No

I don't want to get hacked :-X
>>
>>57687164
> tfw you have a great github but you dont want anyone in SF knowing you browse 4chan
>>
>>57687257
>tfw you have a shit github because your employer owns all your code
>>
>>57687146
uint64_t is optional. Size of double in bytes is implementation-defined. You don't need any union to get representation of an object.
>>
File: 1479459352900.webm (3MB, 320x240px) Image search: [Google]
1479459352900.webm
3MB, 320x240px
>>57687270
>he doesn't spend every waking hour working on either work or public side projects, driving himself to burnout and emotional detachment

these turbo hamps are a metaphor for programming as a career path
>>
>>57687303
They own anything I write outside work too.
>>
>>57687303
I have nothing better to do desu
>>
I want to create a script to linear search an entire text document and output matches. I estimate the document to be maybe 50MB (but possibly more), and speed is a priority.

So far, I am only familiar with Python and a bit of Visual Basic, and I am to understand that Python is an interpreted language, and therefore it will be considerably slower than a compiled language.

Which is my best, viable option?
>Just do it in Python
>get Python to call a VB script to search, and return the results to Python
>script-kiddie up a C script to search, call it and return the results to Python
>>
>>57687326
How the fuck is that legal?
>>
File: fff.png (17KB, 900x900px) Image search: [Google]
fff.png
17KB, 900x900px
Are languages like C, C++, VB, C#, and Java dead now?

Everyone seems to be using laguages like Python, JavaScript (nodejs), Ruby, etc. these days.
>>
>>57687326

No they don't
>>
>>57687109
You can host a static website with unlimited bandwidth for like less than £5 a month, lad.
>>
>>57687146
Also, it contains undefined behavior. Guess where.
>>
>>57687365
lolno only webdevs and hobby-level redditors use those other languages
>>
>>57684195
"Damn, that sounds reasonable. Time for an hero."
>>
>>57687406
I don't know senpai, it seems to be desktop developers too.
>>
>>57687432
not any "developers" worth mentioning
>>
File: 9.jpg (48KB, 492x492px) Image search: [Google]
9.jpg
48KB, 492x492px
>>57687447
I think you're in denial, lad.
>>
>>57687471
>>>/g/wdg
>>
Time to drop the languages of yesterday (C, C++, etc.) and time to focus on the languages of tomorrow (Python, JavaScript, Ruby, etc.)
>>
>>57687353
>>57687375
I signed the contract that says they do. I'm not too fussed about it right now, I'm comfy.
>>
57687511
Not good enough
>>
>>57687511
You mean Haskell, Idris, etc.
>>
>>57687515
> I signed the contract that says they do. I'm not too fussed about it right now, I'm comfy.

Never has the word wageslave been more appropriate, I bet you run proprietary livescript (JavaScript) as well.
>>
>>57687540
I bet you think it's unreasonable that they reserve the right to fire me if I'm convicted of a serious crime or I go into the office drunk, too.

Actually we run statically typed languages for the most part.
>>
>>57687515

> being this cucked

have you thought about not telling them about what you do in your free time
>>
>>57687619
They surveil their present and past employees' online activities, anon.

And if I publish code anonymously, what good does it do me?
>>
>>57687649

so get a computer and don't tell them about it

also if you let them put anything on a computer that you paid for, you should just drink acid
>>
>>57687432
Only people who makes those god awful desktop programs that run a full stack web framework and browser in the background. Honestly those are such a minority unless you're already in that industry (all of those tools are development tools).

C++, C# and Java are all used in enterprise software, very, very frequently. Software for supermarket checkouts to on board car systems to database software for accountants is written in those languages. C++ and VB are more commonly used for legacy codebases written during the late 90s to mid 00s.
>>
>>57687686
I mean they monitor github accounts, etc.
>>
defend yourselves
int overflow_average(int a, int b){
return (a+b)/2;
}

int long_average(int a, int b){
return (int)((long)(a+b) / 2);
}

int double_round_down_average(int a, int b){
return (a/2) + (b/2);
}

int float_average(int a, int b){
return (int)(((float)a)/2.0 + ((float)b)/2.0);
}

int double_float_average(int a, int b){
return (int)(((double)a)/2.0 + ((double)b)/2.0);
}

int low_high_average(int a, int b){
int low, high;
if(a > b){
low = b;
high = a;
}else{
low = a;
high = b;
}
return low + ((high - low) / 2);
}

int half_good_average(int a, int b){
return (a / 2) + (b / 2) + (a & b & 1);
}
overflow_average
Failed -2147483648 -2147483648 with output = 0
Failed -2147483648 -2147483647 with output = 0
Failed -2147483648 -2147483646 with output = 1
Failed -2147483647 -2147483647 with output = 1
Failed -5 -6 with output = -5
Failed 5 6 with output = 5
Failed 2147483647 2147483647 with output = -1
Failed 2147483647 2147483646 with output = -1
Failed 2147483647 2147483645 with output = -2
Failed 2147483646 2147483646 with output = -2
Failed -2147483647 0 with output = -1073741823
Failed 2147483647 0 with output = 1073741823
Failed 2147483647 -2147483648 with output = 0
Total Failures : 13/21

long_average
Failed -2147483648 -2147483648 with output = 0
Failed -2147483648 -2147483647 with output = 0
Failed -2147483648 -2147483646 with output = 1
Failed -2147483647 -2147483647 with output = 1
Failed -5 -6 with output = -5
Failed 5 6 with output = 5
Failed 2147483647 2147483647 with output = -1
Failed 2147483647 2147483646 with output = -1
Failed 2147483647 2147483645 with output = -2
Failed 2147483646 2147483646 with output = -2
Failed -2147483647 0 with output = -1073741823
Failed 2147483647 0 with output = 1073741823
Failed 2147483647 -2147483648 with output = 0
Total Failures : 13/21
>>
>>57687723
>returning an int
>>
>>57687723
double_round_down_average
Failed -2147483648 -2147483647 with output = -2147483647
Failed -2147483647 -2147483647 with output = -2147483646
Failed -7 -5 with output = -5
Failed -5 -6 with output = -5
Failed 5 6 with output = 5
Failed 2147483647 2147483647 with output = 2147483646
Failed 2147483647 2147483646 with output = 2147483646
Failed 2147483647 2147483645 with output = 2147483645
Failed -2147483647 0 with output = -1073741823
Failed 2147483647 0 with output = 1073741823
Total Failures : 10/21

float_average
Failed -2147483648 -2147483646 with output = -2147483648
Failed -2147483647 -2147483647 with output = -2147483648
Failed -5 -6 with output = -5
Failed 5 6 with output = 5
Failed 2147483647 2147483647 with output = -2147483648
Failed 2147483647 2147483646 with output = -2147483648
Failed 2147483647 2147483645 with output = -2147483648
Failed 2147483646 2147483646 with output = -2147483648
Failed 2147483647 -2147483648 with output = 0
Total Failures : 9/21

double_float_average
Failed -2147483648 -2147483647 with output = -2147483647
Failed -5 -6 with output = -5
Failed 5 6 with output = 5
Failed 2147483647 2147483646 with output = 2147483646
Failed -2147483647 0 with output = -1073741823
Failed 2147483647 0 with output = 1073741823
Failed 2147483647 -2147483648 with output = 0
Total Failures : 7/21

low_high_average
Failed 5 6 with output = 5
Failed 2147483647 2147483646 with output = 2147483646
Failed -2147483648 0 with output = 1073741824
Failed 2147483647 0 with output = 1073741823
Failed 2147483647 -2147483648 with output = -2147483648
Failed 2147483647 -2147483647 with output = -2147483648
Total Failures : 6/21
>>
>>57687749
half_good_average
Failed -2147483648 -2147483647 with output = -2147483647
Failed -2147483647 -2147483647 with output = -2147483645
Failed -7 -5 with output = -4
Failed -5 5 with output = 1
Failed -3 3 with output = 1
Failed -5 -6 with output = -5
Failed 5 6 with output = 5
Failed 2147483647 2147483646 with output = 2147483646
Failed -2147483647 0 with output = -1073741823
Failed 2147483647 0 with output = 1073741823
Failed 2147483647 -2147483647 with output = 1
Total Failures : 11/21
>>
>>57687720

use your brain:

make a new shithub
>>
>>57687723
Your long_average is retarded.
>>
I made the mistake of writing a program for WebGL 2, and now I have the problem that if I try downgrade to WebGL 1, it will complain that GLSL 3.00 is not supported.
But, GLSL 3.00 is required for my shaders to work, since apparently "in" and "out" are only supported in that version.
What do?
>>
>>57685263
template {
{x[] for ;(penis()).dick->*dong++10}=5<jizz>};

this is as valid and readable as c++ code
>>
>>57687767
They're all retarded
>>
>>57687844
template <size_t> union { struct { }; x(){ [](const auto&&){for(;;){ nullptr->size(); }}}}
>>
>>57687903
non-retarded version should be fine
int long_average(int a, int b) { return ((long)a + b) / 2; }
>>
>>57687922
template <size_t> union {
struct { };
x() {
[](const auto&&) {
for (;;) {
nullptr->size();
}
}
}
}
>>
>>57687947
Failed 7/21
>>
>>57687955
Wow, so readable.
>>
How do I compute the average of two ints in Idris?
>>
>>57687984
Yes, it means fine. >>57687741
>>
>>57687955

Beautiful.
>>
>>57688019
It's fine if you failed 3rd grade
>>
struct foo {
struct foo bar;
}


What will happen?
>>
>>57687723
Do it with my arbitrary int averaging function:
#include <stdlib.h>

int iavg(int n, const int arr[static const n])
{
int avg = 0;
int rem[2] = {0, 0};
int add[2] = {0, 0};

for (int i = 0; i < n; ++i) {
avg += arr[i] / n;

int a = abs(arr[i] % n);
int j = arr[i] < 0;

if (rem[j] >= n - a) {
rem[j] = a - (n - rem[j]);
++add[j];
} else {
rem[j] += a;
}
}

avg += add[0] - add[1];

if (avg < 0 && rem[0] > rem[1])
++avg;
else if (avg > 0 && rem[0] < rem[1])
--avg;

return avg;
}
>>
>>57688045
the person who wrote tests actually failed
>>
>>57688048
It won't work.
>>
>>57684119
I love Haskell.
ref: http://learnyouahaskell.com/
>>
>yet another node.js video that starts out with a long-winded "story" to explain something so simple it's intuitive for most people
Must be a sort of meme within the industry. Wish it would stop.
>>
>>57688110
https://youtu.be/ame2PH67gnk
>>
>>57688049
You won, according to the test
>>
>>57688110
Why the fuck is node.js even a thing?

It's bad enough running JS on the client side, but on the server? What a fucking disaster, I mean it's a catastrophe.
>>
Android dev

>Code compiles perfectly on my Samsung S4
>Code compiles perfectly on the LG G5 emulator
>Errors when I try and compile on my new LG G5 phone

What do?
Googling the error code gives me no useful information
>>
>>57687387
You can host a dynamic website for less than that.
>>
>>57688151
I know it's a troll but fucking hell I'm mad
>>

avg :: Integral a => a -> a -> Ratio a
avg 0 m = m % 2
avg n 0 = n % 2
avg n m | n == m = n % 1
| 0 > n || m < 0 = avg (n + 1) (m + 1) - 1
| otherwise = avg (n - 1) (m - 1) + 1


inb4 >C
>>
>>57687387
You can host a static site for free on github.
>>
>>57688203
oh, and
import Data.Ratio (Ratio, (%))
>>
This is my averageing function in C it computes the average of an integer pls rate I spent several times on it

int64_t f(uint8_t n)
{
if (n <= 1) return n;
if (n > 92) return -1;
n -= 2;

uint64_t a = 1, b = 1, c = 0, d = 1, e = 1, f = 0;

while (n) {
uint64_t g, h;
if (n & 1) {
g = a * d + b * e;
h = b * d + c * e;
f = b * e + c * f;
d = g;
e = h;
}
g = a * b + b * c;
a = a * a + b * b;
c = b * b + c * c;
b = g;
n >>= 1;
}

return d;
}
>>
>>57688205
Yeah, but only for certain things:

>You may use the GitHub Pages static hosting service solely as permitted and intended to host your organization pages, personal pages, or project pages, and for no other purpose.
>>
>>57688181
Where? And with unlimited bandwidth?
>>
>>57688161
Node.js is the only real dev language
>>
>>57688162
>tfw he fell for the G5 meme too
>>
>>57688181
If you're paying less than $5/mo for hosting, especially if its not just static content, and especially if you're given "unlimited bandwidth", you're probably with a shit host.
>>
>>57688049
>>57688159
Oops, nevermind, you fail for the same reasons double failed
>>
>tfw too retarded to complete pset 4 of CS50
Should I just quit programming while I'm ahead?
>>
>>57688310
I wanted a phone with a USB-C port, I'll still use my Samsung for everything but compiling

What's this G5 meme you speak of?
>>
>>57688326
giving up is not an option.
>>
Ok so first at the start of my script it print ascii art
P R O J E C T  N A M E
By x

does this make you think I made the script or that I made the ascii art?

also is there anyway in python (3.x) to center the ascii art in the terminal, heres the code I'm using for it
a = """
P
R
O
J
E
C
T
print(a)
>>
>>57688225
>the average of an integer
You fucking what? Can somebody please explain to me what this shit does?
>>
>>57688338
the build quality is questionable. the screen scratched in my pockets pretty badly and the bottom piece pops out on its own a lot. screen burn-in is pretty severe, but it's temporary unlike with my old AMOLED phone.
>>
>>57688397
>the build quality is questionable. the screen scratched in my pockets pretty badly and the bottom piece pops out on its own a lot

This is okay, I plan on having it sat on my desk for the next 2 years used only to run my .apks

Cheers for the warning though, I'll get a screen protector for it
>>
>>57684790
what licences make you give credit to the original programmer?
>>
>>57686794
>>57686365
Standards nazi's like you bicker about compiler options while people like Carmack write really neat hacks that actually gets shit done, as their target platform is very specific (specific enough to recognize the need for 32-bit-float->long hacks)
>>
>>57688358
You could uses curses/ncurses to get the width of the terminal. Once you know that, centering is simple.
>>
File: 9999999999%FURRYIOUS.gif (495KB, 618x648px) Image search: [Google]
9999999999%FURRYIOUS.gif
495KB, 618x648px
>>57687784
Now I'm trying to show my LDR boyfriend what I made but he is being ultra-stubborn about enabling WebGL2.
I really need some backwards compatibility in my program.
>>
>>57687109
I bought a VPS for $10 for 3 months... it's only expensive if you have high standards ;-))
>>
>>57688162
what's the error?
>>
Why the hell isn't my Java Hello World program compiling?
>>
File: 1105553.jpg (28KB, 640x480px) Image search: [Google]
1105553.jpg
28KB, 640x480px
I want to learn programming, but I'm really bad at algorithms, is there any book to help me with this? I use way too many for loops and if statements.
>>
>>57688515
1-26 01:16:10.311 30390-30415/com.practice.game E/AndroidRuntime: FATAL EXCEPTION: GLThread 1072
Process: com.practice.game, PID: 30390
java.lang.ExceptionInInitializerError
at com.practice.game.Screens.PlayScreen.<init>(PlayScreen.java:94)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load shared library 'gdx-liquidfun' for target: Linux, 32-bit
at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:118)
Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.practice.game-2/base.apk"],nativeLibraryDirectories=[/data/app/com.practice.game-2/lib/arm64, /data/app/com.practice.game-2/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libgdx-liquidfun.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)


It's saying that it can't find gdx-liquidfun for linux 32-bit, but the phone doesn't even need linux 32-bit surely?
LG G5, standard software, running android 24 i think
>>
At what point in learning programming did you reach a point where you realized "I actually understand what I'm doing!"?
>>
>>57688562
The moment you think you understand me is the moment you lose, kiddo
>>
>>57688522
Okay I figured it out. Apparently java can't find the program unless you specify the current directory in classpath.

I don't remember this being an issue before though. Did something change recently?
>>
>>57688522
does it work if you do `java -cp . Hello`?
>>
>>57688651
ah 2laet>>57688624
>>
I had an interview today, but they said they don't do code :^)
>>
>>57688680
Were you the interviewer, the interviewee or the interview?
>>
>>57688722
interviewee
>>
>>57688740
Did you consent to the interview?
>>
>>57688781
Yeah, i went there but they had a vague description of their work roles, i'll probably get a job at their IT, but whatever i need money.
>>
>>57688380
Run it and see?
>>
Alright, I got a new window with ncurses, please excuse the shit diagram here:

-------------
|Box for nig|
|gers |
-------------


Without using regex is there a way to either have the line break it apart like ni-
ggers

or, possibly even easier just a new line before niggers?
>>
>>57688557

I'm going to guess you're using a 32-bit library in a 64-bit application, right?
>>
File: c.png (98KB, 741x835px) Image search: [Google]
c.png
98KB, 741x835px
Well /g/, how good are you at C?
>>
>>57688380
>You fucking what?
Anon did you fail 6th grade math
>>
>>57688421
oh, make sure to have a screen protector that goes all the way to the top. the scratches happened opposite of the front camera where my screen protector wasn't covering
>>
>>57688541
Read SICP. No, really.
>>
#include <stdio.h>
#include <stdbool.h>

int main(int whatever, char **fuck_you) {
for (int i = 1; i <= 100; ++i) {
bool printed = false;

if (i % 3 == 0) {
printf("Fuck");
printed = true;
}

if (i % 5 == 0) {
printf("Butt");
printed = true;
}

if (!printed) {
printf("%d", i);
}

printf("\n");
}

return 0;
}


Do I get the job?
>>
>>57688933
That's exactly right!

I've tried the below, but gradle doesn't recognise ndk or defaultConfig, so I'm stuck
android {
....
defaultConfig {
....
ndk {
abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
}
}
}


Any suggestions?
>>
File: 1479405735367.png (541KB, 1159x591px) Image search: [Google]
1479405735367.png
541KB, 1159x591px
>>57688962
>using recursion in C
>>
>>57688541
https://www.manning.com/books/type-driven-development-with-idris

https://www.youtube.com/watch?v=Bxcz23GOJqc

http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesALaCarte.pdf
>>
>>57689020
You can use it, gcc supports tail-call optimization.
>>
>>57689000
>trips
>"printed" variable instead of if-else branch
absolute madman
>>
>>57688924
>Without using regex is there a way to either have the line break it apart like ni-
>ggers

Why would you use regex for that? Just count through each word, keeping track of how many spaces are left within the line.

If a word doesn't fit, break it part with a -.
>>
>>57688924
Yes
>>
>>57689045
I expect $300k and stock
>>
Working on this in Visual Studio.
im trying to have a C# GUI interact with some C++ code that a made awhile ago.
the line that doesn't work works just fine in the cpp file.
in the .cs file it says that i cant implicitly convert type int*[] to int**
what do?

 
unsafe
{
fixed (int*** parr = new int**[9])
{
for (int i = 0; i < 9; i++)
{
parr[i] = new int*[9]; //this part doesnt work
}
for (int i = 0; i < 9; ++i)
{
for (int j = 0; j < 9; ++j)
{
parr[i][j] = null;
}
}

}
>>
I've been working on this bit of brainfuck
>>
>>57689116
Fok, I can't do 4chen. Here it is:
-[------->+<]>--.+[->++++<]>.[-->+++++<]>-.+[----->++<]>...+++[->++<]>.[-->+<]>---.>-[--->+<]>.[----->++<]>--.+[->++<]>+.-[-->+<]>-.--[-->+++++<]>.---[->++++<]>...--[->+++<]>-.+[--->+<]>++.[-->+++++<]>-.+[----->++<]>.>-[--->+<]>.[----->++<]>--.>-[--->+<]>---.--[----->++<]>.>-[--->+<]>--.+[--->+<]>++++.++[->++<]>+.-[-->+<]>--.++++++[->++<]>.[-->+<]>------.+++[->++<]>.>++++++++++.[->++++++++<]>-.>++++++++++..[->+++++++<]>.>++++++++++.>-[--->+<]>.>++++++++++.+[->++++++<]>+.>++++++++++.[------->++<]>-.>++++++++++..+[--->+<]>.[->+++<]>-.[->++++++++<]>-.>++++++++++.>-[--->+<]>.>++++++++++.>-[--->+<]>---.>++++++++++.>-[--->+<]>--.>++++++++++.[->+++++++<]>-.>++++++++++.[------->++<]>.>++++++++++.[->+++++++<]>.
>>
>>57689040

Technically, the code shown is not tail recursive. But then again, it wouldn't be able to be optimized in other languages either because of this.
>>
>>57688962
Thats doing a quicksort right?
>>
>>57689159
It wouldn't blow the stack in Haskell
>>
>>57688077
>he can't solve the problem
>>
>>57689159
Not technically, it isn't at all. It isn't valid for tail recursion at all because its first call to itself has to build recursive stacks and store the next call to itself. My point was that doing recursion in C is very much possible, in general, because GCC can tail call optimize.
>>
>>57689169
That does appear to be the intent of the code.
>>
Is Programming gay?
>>
>>57689245
usually.
>>
>>57689077
I think that helps, thank you
>>
Writing a CHIP-8 Emulator to practice over the weekend, but have absolutely no idea about OpenGL, SDL, and DirectX
Using this emulator,
http://www.multigesture.net/articles/how-to-write-an-emulator-chip-8-interpreter/

And I have no idea which books/references I could use to read up on them... I tried the OpenGL SuperBible, but that's written for Windows (would it still work for Mac, despite it using Visual Basic)?

Thanks in advice
>>
File: java.png (110KB, 734x655px) Image search: [Google]
java.png
110KB, 734x655px
Can you do this, /g/?
>>
>>57689245
only if you blow the stack
>>
>>57689447
yes, I've done it in OCaml
>>
>>57689465
Can you do it in Java though?
>>
>>57689427
>I tried the OpenGL SuperBible, but that's written for Windows (would it still work for Mac, despite it using Visual Basic)?
Why would you download the first edition of a book that was originally published like 20 years ago and covers an incredibly outdated version of the api you want to learn? Are you fucking retarded?
>>
>>57687749
half of those aren't even failures retard
>>
>>57688077
this

>>57689181
kill yourself
>>
>>57689531
>>57689546
>0.5 rounds to 0
>>
>>57689557
std::cout << 1/2;
>>
>>57689566
Kek, go back to school
>>
>>57689575
shitty bait
>>
>>57689483
of course, I'm on my phone right now though
>>
New thread: >>57689596
>>
>>57689582
It's not bait, you're just stupid
>>
>>57688562
not reached it yet, on every new project I learn at least one new thing or improve on something I already knew
>>
>>57689617
(You)
>>
>>57689484
Seventh edition, friend!
>>
>>57690098
Well the 7th edition uses C (or C++ I forget) and literally directly covers both OS X and Linux. And mobile, if I'm not mistaken.
>>
>>57689106
>>57689882
>>
>>57689675
at least be consistent with math.h
>>
>>57687723
>>57687749
Ints aren't supposed to go up that high brah. You're thinking of long ints
>>
>>57690137
math.h doesn't have an int average function
>>
>>57684873
editor name pls?
>>
>>57690278
it has a double to long round function, that rounds away from 0.
>>
>>57690529
we are averaging ints, not doubles, and truncating is a valid way to round an integer
>>
it's inconsistent with how math.h thinks of numbers, which is reason enough to consider it invalid. If math.h rounded 'up' then it would be, but it doesn't.
>>
I always see people hooking functions in windows processes, but what about doing so in Linux processes?
>>
I wanna store a SQLite database on a Raspberry Pi; what level and what means of security do I need to put on it if the database will include rather sensitive info? The database will be accessed by me and several other people, so proper and secure access via internet is required.
Thread posts: 327
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.