Vlad
The output of this code “i’m in scope” why?
Because unsigned int truncates to char on comparision
Vlad
Basically it does x == (y & 0xFF)
R
Is c++ primer 5th edition is good to get started with c++
Anonymous
If you wanna learn some c++11 then better choose 6th edition
R
I want learn at beginners stage
R
Which YouTube you can recommend apart from new boston
Anonymous
Don't watch vedio, read book and go through example
Vlad
I want learn at beginners stage
Well I'd recommend learning c++11 first. And then learn legacy stuff only when needed.
R
Thank you for help 😊
布丁
rust being memory safe means it must have sacrificed some execution speed
that is a common misconception. Most of the checks are done at compile time
Vitaliy ◀️TriΔng3l▶️
Because unsigned int truncates to char on comparision
Waaait… Not the char (I assume signed here) gets promoted to signed int?
Vitaliy ◀️TriΔng3l▶️
Anonymous
(unsigned)-1 == UINT_MAX
Anonymous
Through signed?
Doesn't matter
Vlad
Well that's weird that 0xFF promotes to 0xFFFFFFFF. Guess I'm gonna have to roll with it tho :P
Vitaliy ◀️TriΔng3l▶️
Anonymous
Through signed?
char can be either signed or unsigned — it depends on a compiler At least that's the rules in C++
Vlad
char can be either signed or unsigned — it depends on a compiler At least that's the rules in C++
And additional bonus for a changed behavior once char is unsigned in the system.
Vlad
Well played :P
Vitaliy ◀️TriΔng3l▶️
#include <stdint.h> uint32_t to_uint32(int8_t i8) { return uint32_t(i8); } movsx ooooh :o
Vitaliy ◀️TriΔng3l▶️
but well, makes sense, for instance, if it was float rather that int8_t
Vitaliy ◀️TriΔng3l▶️
respecting traits of the original type
Emir
The output of this code “i’m in scope” why?
So when we comparing to different size variable the small one promoted the big one, is it true? are line comments true? bits?
Vitaliy ◀️TriΔng3l▶️
Bits are not true if it's two's complement
Vitaliy ◀️TriΔng3l▶️
But yes
Emir
Bits are not true if it's two's complement
how can i see my variable on ram? is it possible?
Vitaliy ◀️TriΔng3l▶️
how can i see my variable on ram? is it possible?
You can print it with an unsigned format (like %hhx for printing an unsigned char as hexadecimal), or use memory view in a debugger
Anonymous
#include<stdio.h> #define my_sizeof(type) (char *)(&type+1)-(char*)(&type) int main() { double x; printf("%ld", my_sizeof(x)); return 0; } Hi, Guys, I am confused about this program, why does it result 8? Thanks in advance
Vitaliy ◀️TriΔng3l▶️
has CLion memory view?
Yes, see Google Images how to access it and display variables in it
Anonymous
double occupies 8 bytes
I know this, but confused about expression (char *)(&type+1)-(char*)(&type)
Vlad
I know this, but confused about expression (char *)(&type+1)-(char*)(&type)
If you're incrementing pointer to a variable it increments by it's size.
Anonymous
Thanks
Ismael
/ban
Ismael
/add
RAMP
Hi
M__
i am trying to build a game using C and i couldnt seem to find any source for function : delay();
M__
how do i implement delay() using for loop ?
Alex
use sleep
M__
sleep(millisecond) ? whicch header file
Alex
#include <unistd.h> int usleep(useconds_t usec);
Asdew
$ man 3 sleep
Stefan
how do i implement delay() using for loop ?
you need to find cpu cycle timing firsr
V01D
If so, you might have a sleep function for the API. For SDL2 it is SDL_Delay(time); for example
V01D
you need to find cpu cycle timing firsr
That's a little extreme, no need to reinvent the wheel. (Unless I am missing something, but the whole rdtsc instruction idea seems a bit OP.)
V01D
Has any one worked with audio in C? More specifically in calculating the FFT, and finally the power spectrum of a sample? I am working on this, for an audio visualizer and was wondering if any one has a library they can recommend to work with FFT. (I am thinking about SFML, fftw3, or kiss FFT. (Open for anything new, too))
M__
Are you using a graphics api like SDL2?
I'm Not using graphics library for now Just trying to build snake game
V01D
Ok
V01D
Ok, cool
Vlad
Or it's some unistd.h implementation?
piggyho
/get rules
Anonymous
guys wtf
Anonymous
how does C99 complex.h have an operator overload for complex multiplication ?
Anonymous
@unterumarmung is the openapi parallel compiler a separate compiler or they just contribute their changes to clang?
Anonymous
oh i found some documentation on building
Anonymous
github.com/intel/llvm
Anonymous
OneTBB for example doesn't depend on DPC++ compiler
Anonymous
OneMKL afaik either has some features for DPC++ or depends on DPC++ compiler
Anonymous
oh
Sherlock
How to pass 2d array on c in a function? I looked or up on geeks for geeks but Hacker rank shows error that way
Daniele
what's a 2d array?
Daniele
a matrix?
V01D
Lol.
Anonymous
I meant something different and that's why deleted this
Anonymous
Yep
Lol