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.
LMAO THE ABSOLUTE STATE OF Jow Forums What the fuck do these people even do on this board
Adrian Richardson
>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?
Robert Martin
>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.
Asher Martinez
shitpost about languages
Owen Roberts
You have to use something like curses.
Colton Thomas
Only since C++17, it was undefined before.
Jonathan Morales
>the C++ programmer doesn't know the actual meaning of const volatile
Mason Young
"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
Caleb Howard
>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.
Owen Collins
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 }
Gabriel Lopez
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
Matthew Johnson
It's beautiful.
Liam Watson
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?
Jonathan Rodriguez
>Ret < Number sqrt(1)
Hunter Martin
>not using terse syntax template Also >inline static constexpr 2/10 see me after class
Joseph Perry
In fact, that's not true for any input in the interval [0,1].
Isaac Perry
who needs templates or constexpr apart from stl/boost nerds lmao
Adam Phillips
>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]] { // ... }
John Morales
People who write real programs.
Sebastian Bennett
>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
Are unpaid programming internships unironically a thing in the land of the free? how the fuck do you cope dudes
Wyatt Miller
if you're referring to my post, this was in southern yourop
Daniel Taylor
Default 'real' type in Fortran is 32-bit. Maybe there's some rounding going on behind the scenes.
Jaxson Bennett
Loans, drugs, lots of crying and bootlicking. Be grateful for the opportunity.
Jaxon Green
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.
Jonathan Reyes
I've never seen one of those here in burger. Unpaid internships are for humanities majors.
Certain numbers just can't be represented in certain bases. It's the same reason 1/3 can't be represented properly in decimal.
Sebastian Taylor
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?
Lucas Kelly
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.
Ethan Cruz
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.
Elijah Lewis
use the modulo operator. I've done that before.
Nathaniel Ross
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
Wyatt Martin
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.
Isaiah Powell
You can just use arbitrary precision types. Floats are intentionally approximate and fast.
Jaxon Perry
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?
Hunter Hall
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
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)
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.
Aiden Anderson
that would be a hard version of facial recognition lol