DPT - Daily Programming Thread

Previous: (Cross-thread)

This is the official thread. All others are invalid.

Remember, this is the daily _programming_ thread.
This means you are only allowed to discuss modern C++ and cute 2D girls.
All other languages go to Traps, "girl (male)"s, 3DPD, fr*gposters, and w*jak posters go to Please remember to vary your cute 2D girls, don't just post the same characters from the same shows/manga/VNs/whatever over and over again that people have already posted a quadrillion times. Post something that hasn't been posted much before, make sure it's cute and high quality.
Please refrain from posting or discussing code that isn't zero overhead.
C """programmers""": You are not allowed to post or discuss C code that isn't also valid C++, as that isn't programming related. You are still not allowed to explicitly discuss C only, as that is of course not programming related either.
Remember to appreciate lovely and cute 2D girls and tease their cute little nipples into submission by rubbing them gently and lovingly with your hands and licking/sucking on them with your tongue/mouth.

No one fucking cares what you're working on.

Attached: 1537559013923.jpg (1021x1300, 221K)

Other urls found in this thread:

ideone.com/S4Oteo
cs.ukzn.ac.za/~hughm/os/notes/ncurses.html#input
twitter.com/SFWRedditGifs

Lisp is the most powerful programming language.

First for Windows, C#, C++ and other Microsoft goodies.

>butchering the op
fek off will ya lad

Can we please have a non-shit new thread. Thanks

First for Erlang

Why the fuck can't we discuss C

This is the non shit thread.

Not programming related.

its just shitposting

Just pretend you're trying to discuss C++ but are too retarded to understand OOP, templates, const, or operator overloading

C users don't need to pretend in that case.
They're already too retarded.

>retarded OP
>shitty blogpost no one cares about
At least they're a link to previous thread and anime picture, but you should still kill yourself.

>const
Lmao do C users really consider const an "advanced" C++ feature?

No blogposting senpai. Just guidelines.

pls dont bully c
im just a beginner ;_;

>mfw even the retarded sepplesfag makes better threads than previous OP

JavaScript rocks!

Attached: js-rocks.png (1000x494, 369K)

I've got about a billion duplicates of this.
I can't stop saving it.

var x = [0];
x==x;
x==!x;


Wow. Some language you got there.

0.1+0.2==0.3


false. Nice.

>he doesn't understand IEEE754

Makes sense.

IEEE754 was a mistake. Posits > floats

>tfw never even realized there was a tagline there
Are there actually variations?

pic related

Attached: 20130605.png (612x727, 65K)

Name one(1) language that doesn't behave like this. Arbitrary precision and decimal don't count, we are talking about floating point.

Someone redbulls me on F-bounded polymorphism

>Are there actually variations?
No I just keep saving the same image over and over again like a retard because I'm autistic.

CL-USER> (= (+ 0.1 0.2) 0.3)
T

Attached: 124532112.jpg (1052x1052, 76K)

Do C++ "programmers" even know what a volatile const is?

Attached: 1531823191070.png (480x800, 309K)

Too bad Lisp isn't programming.

>can't represent 1/3 in a finite decimal fraction
Nice math you got here, human, meanwhile in ternary it's simply 0.1.

Yeah, I need to use volatile when I use C++ on microcontrollers.

They do.

Is this supposed to be a difficult question?

It's a big fat misnomer is what it is.

C++

#include
using namespace std;

int main() {
// your code goes here
float result = 0.1 + 0.2;
std::cout

0.3 is not 1/3. Stay in school kid.

Based Sepples

Read only and not allowed to optimize out or reorder accesses.
Next.

>I'll round double to float, that'll show him!

>using namespace std
>still using std::
How redundant.

Read the post again. Carefully.

Big think.
ideone.com/S4Oteo

get out normie

One thing people tend to miss is that reading a volatile variable is a side-effect. Thus, using x + x where x is volatile would be UB.

Unspecified, not undefined.

You don't know what that U stands for

Attached: 1504412544627.jpg (2378x1783, 225K)

LMAO
THE ABSOLUTE STATE OF Jow Forums
What the fuck do these people even do on this board

>making a pong clone in C
So in my main loop I'm moving the ball as well as the paddle, but to move the paddle I need a input, because of that the loop comes to a halt and will only continue if a input is given. This halt in the loop causes the ball to stop moving.
So, my question is how can I take input without disrupting the movement of the ball in the loop?

>Thus, using x + x where x is volatile would be UB.
Even if x is const volatile?
It makes sense if it wasn't const, because x could change in between reads but if it's const then I can't see how it would be undefined or unspecified.

shitpost about languages

You have to use something like curses.

Only since C++17, it was undefined before.

>the C++ programmer doesn't know the actual meaning of const volatile

"const" doesn't mean "constant", which is why "volatile const" is meaningful. Say you're monitoring a counter that always increments. The thing is, c

>const volatile
The fact that it is const for your program doesn't mean shit to your compiler, the fact it's volatile specifically means your hardware may fuck with your variable however it wants.

template // template header
requires std::is_arithmetic_v // template constraints
inline static constexpr // silly keywords
auto sqrt(const T &Number) noexcept -> T // function signature
[[expects: Number >= 0]] // contracts ...
[[ensures Ret: Ret >= 0 && Ret < Number]] // ... one per line
{
// Implementation comes here
}

What's going on in here
! Testing floating-point arithmetic
program real_num
implicit none

real :: num
logical :: equals_0_3

num = 0.1 + 0.2
equals_0_3 = num == 0.3

if (equals_0_3) then
print *, 'true'
else
print *, 'false'
end if

print '(a, f12.10)', 'num is: ', num

end program


Output:
$ ./real_num true
num is: 0.3000000119

It's beautiful.

I'm using ncurses. For input I'm using getch().
Beacuse of getch, the loop stops for taking the input.
How can I let getch() look for input without affecting the loop?

>Ret < Number
sqrt(1)

>not using terse syntax
template
Also
>inline static constexpr
2/10 see me after class

In fact, that's not true for any input in the interval [0,1].

who needs templates or constexpr apart from stl/boost nerds lmao

>Look at me I can write purposely verbose code
template
static constexpr T sqrt(const T &x) noexcept
[[expects: x >= 0]]
[[ensures r: r >= 0 && r < x]]
{
// ...
}

People who write real programs.

>be me
>last year of college
>have to do internship (1 semester + 2 semester = 10 months)
>apply for *paid* internship
>first week they tell me they will only pay me on the second semester of the internship
>internship application doesn't say nothing about this
>ignore
>2 months to the end of the internship
>still not paid
>they get mad when i don't do the work they told me to do

Attached: 1540687973663s.jpg (225x225, 6K)

So, the question is WHY does it do this?

>>be me
There's your problem

so much better

Attached: 1467019345752.jpg (180x157, 10K)

Yeah I forgot to add a space after the template keyword, just pretend it's there no need to bleed your eyes out.

Attached: mhkr53nw5qu11.png (1006x345, 88K)

Are unpaid programming internships unironically a thing in the land of the free? how the fuck do you cope dudes

if you're referring to my post, this was in southern yourop

Default 'real' type in Fortran is 32-bit. Maybe there's some rounding going on behind the scenes.

Loans, drugs, lots of crying and bootlicking. Be grateful for the opportunity.

Yeah but how the fuck does .1 = .100000001 or whatever? You'd think a float would assume all unused decimal points were zero unless specified otherwise.

I've never seen one of those here in burger. Unpaid internships are for humanities majors.

man pages are great albeit an acquired taste

Attached: man.jpg (726x952, 107K)

Certain numbers just can't be represented in certain bases. It's the same reason 1/3 can't be represented properly in decimal.

Okay guys need a bit of advice with a problem.

I'm using matlab, but concept is the same regardless. Need to simulate taking random steps in a space that is size 50x50 (for example). Basically, I draw a direction and a step length at random.

This is all simple enough. The problem is the boundaries. What I'm wanting is periodic boundary conditions. For example, when the step would go outside the top of the square, it instead carries on from the bottom. It "wraps around".

So for each step, if I have two sets of coordinates (xn,yn) and (xn+1,yn+1), how do I figure out if and how to wrap it around. I can do it with a whole heap of messy if statements just wondering if there's a better way?

Vastly oversimplifying, floats can only represent rationals with power of 2 denominators. So 0.1 = 1/10 cannot be exactly represented. Only something close, like 102/1024.

Ah, I think I get what you're saying. Its still a funny little bug-lite though that should be fixed if it ever became an issue.

use the modulo operator. I've done that before.

cs.ukzn.ac.za/~hughm/os/notes/ncurses.html#input
No delaying. Usually a call to getch() waits until a key is hit. If you have called nodelay(stdscr, TRUE), then getch() will work in a non-blocking manner -- it will return ERR if the key input is not ready. This is usually useful for writing game-like programs, where the promptness of user response matters. For example

It's not gonna happen unless we get computers that use digits instead of bits. Until then, you have to use some other representation and deal with the overhead.

You can just use arbitrary precision types. Floats are intentionally approximate and fast.

I know python isn't very popular here, but still.
a, b, c = 5, 6, 7
l - [a, b, c]

for i in l:
i += 1
print(l) # prints [5, 6, 7], so the above loop does nothing

for i in range(len(l)):
l[i] += 1
print(l) # prints [6, 7, 8], however...
print(a, b, c) # prints 5, 6, 7


So. how would I change a, b, c through the list?

i ignored everything else i was supposed to do for a while but i finally made this script to scrape the best parts of a given pornhub video, feels kinda good

Is Go a good language?

Attached: 0296c360.jpg (544x638, 33K)

yes, i have seen cases where you take a formation for free but you are then not paid for the internship which will pay the formation you took (so, the formations is actually not free)

It achieves its goal.

no

Attached: 1540181796758.png (1280x720, 1.23M)

Attached: 697ddf4a.jpg (240x213, 8K)

I always thought that when I get good enough, I'll do an application called facial recognition, which automatically creates cumshot compilations from videos on pornhub.

that would be a hard version of facial recognition lol

Attached: Chaika!.jpg (487x460, 77K)

>trying to learn programming and a foreign language at the same time

Attached: 1468959619880.png (650x773, 47K)

Are you me?

Which language and which language?

>Coroutining Folds with Hyperfunctions

Attached: 2v1uhaay0n9y.png (1144x888, 409K)