Anonymous
wow it doesnt o.o
Anonymous
[Running ] Test: test_int [Running OK] Test: test_int [Running ] Test: test_int_flipped [Running OK] Test: test_int_flipped [Running ] Test: test_int_zero [Running OK] Test: test_int_zero [Running ] Test: test_long [Running OK] Test: test_long [Running ] Test: test_long_flipped [Running OK] Test: test_long_flipped [Running ] Test: test_long_zero [Running OK] Test: test_long_zero [Running ] Test: test_uint [Running OK] Test: test_uint [Running ] Test: test_uint_flipped [Running OK] Test: test_uint_flipped [Running ] Test: test_uint_zero [Running OK] Test: test_uint_zero [Running ] Test: test_ulong [Running OK] Test: test_ulong [Running ] Test: test_ulong_flipped [Running OK] Test: test_ulong_flipped [Running ] Test: test_ulong_zero [Running OK] Test: test_ulong_zero
Alviro Iskandar
FPU pipeline works almost concurrently
how is that relevant with FPU? there is no floating point here
Anonymous
would probs "overflow" if given zero
Anonymous
since x + 0 is x
Alviro Iskandar
i really suggest you to use builtin, it's fast the compiler only needs to check for OF (overflow flag) on x86 if you use the builtin https://godbolt.org/z/rMdxzz1vz
Alviro Iskandar
apart from that, it saves some hassle playing with complicated bit hacks
Vlad
how is that relevant with FPU? there is no floating point here
It was about checking overflow through a double value
Anonymous
wait, subtraction and division can be implemented via addition and multiplication right?
Anonymous
welp (uint)1 + ~(uint)1 + (uint)1 doesnt work, but (int)1 + ~(int)1 + (int)1 does
Anonymous
https://electronics.stackexchange.com/a/98023
Anonymous
Hello guys, is it possible for a for loop to execute if one variable is undeclared? Btw, I'm still a new in c programming
Vlad
Doesn't mean it's gonna be fast
Vlad
Especially division
Anonymous
what would be a better way?
Vlad
integer division cant overflow
Vlad
Just check for a zero
Anonymous
apparently it can
Anonymous
INT_MAX / -1
Vlad
INT_MAX / -1
Isn't it INT_MIN-1?
Anonymous
yea
Anonymous
INT_MIN / -1
Vlad
INT_MIN / -1
Yeah that's gonna blow
Vlad
But that's like 2 cases total
Anonymous
-2147483648
Vlad
a / b 😂
It's probably could be made faster if you convert it to float
Vlad
Although some accuracy will suffer
Anonymous
welp, lets ignore division for now
Anonymous
how do i detect a subtraction overflow
Vlad
how do i detect a subtraction overflow
substraction is basically addition of uint's if you have a two complement integer
Vlad
And you do basically everywhere
Anonymous
how would you detect it
klimi
if a is negative and b is negative but the result is positive
Anonymous
how would i detect that using bit shifting
klimi
oh i thought you wanted to do this in C, are you doing it in hardware?
Anonymous
hmmm
Anonymous
https://rextester.com/YWUQ96880
Anonymous
which one of these SHOULD overflow? signed 1073741823 + 1073741823 = 2147483646 (overflowed: false) signed 1073741824 + 1073741823 = 2147483647 (overflowed: false) signed 1 + 2147483647 = -2147483648 (overflowed: true) signed 1 + 1 = 2 (overflowed: false) signed 1 + -1 = 0 (overflowed: false) signed -1 + -1 = -2 (overflowed: false) signed -1 + 1 = 0 (overflowed: false) signed 1 + 2 = 3 (overflowed: false) signed 1 + -2 = -1 (overflowed: false) signed -1 + -2 = -3 (overflowed: false) signed -1 + 2 = 1 (overflowed: false) signed 2 + 1 = 3 (overflowed: false) signed 2 + -1 = 1 (overflowed: false) signed -2 + -1 = -3 (overflowed: false) signed -2 + 1 = -1 (overflowed: false)
Grigoriy
I write volatile bool* b;. Is b a pointer to volatile boolean variable or it is a volatile pointer to boolean variable?
Grigoriy
Thanks
.
hi guys, i cant understand where my mistake is. can you fix it?
.
C code to find the sum of the principal diagonal of a 10x10 matrix consisting of random numbers from 1 to 10
.
#include <stdio.h> #include<conio.h> #include<time.h> int main () { srand(time(NULL)); int n, i, j, sum; sum =0; int mat[i][j]; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { n=rand()%100; printf("%d. satir ,%d.sutun elemani : ",i,j); mat[i][j]=n; }} for(i=0;i<=10;i++) { sum= sum+n; printf("Sum : %d",mat[i][j]); } getch(); }
AKI David
I tried printing out the values for i and J and this is the size of the matrix you made: This is i 16 This is j 467
AKI David
so it's a 16x467 matrix
AKI David
#include <stdio.h> #include<conio.h> #include<time.h> int main () { srand(time(NULL)); int n, i, j, sum; sum =0; int mat[10][10]; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { n=rand()%100; printf("%d. satir ,%d.sutun elemani : ",i,j); mat[i][j]=n; }} for(i=0;i<=10;i++) { sum= sum+n; printf("Sum : %d",mat[i][j]); } getch(); }
Anonymous
Hello everyone. What if I going to make an application that should be written many different languages? Is there any alternative environments or applications to do this?
Pavel
Hello everyone. What if I going to make an application that should be written many different languages? Is there any alternative environments or applications to do this?
There's Haxe that can be cross-compiled into multiple languages Also libraries with C interface can be used with many languages, but this can be a lot of headache
abc
How can I read binary format of directory structure in c++? Is there any way?
abc
I trying to make application like winrar to make a single file which contains a directory
Hussein
I trying to make application like winrar to make a single file which contains a directory
the first six bytes let it be the number of directories and the next ones let it be for where does the first directory start and then the number of files then 6 bytes points to where your file starts
Hussein
It would be like this [number of folders][pointer to folder 1 ][2][3]... then each folder may have more folders implemented like how I showed you earlier then if there were files in the folder remember pointer that pointed to folder 1 this will point to a table of the content of the each file then files will be written one after the other
Hussein
Thank you so much, I understood the most of the part but How can I unzip this?
you have a table for the first directory then a table points to each subdirectory inside it with their names then a table for each file in the first directory with each file name
Hussein
Thank you so much, I understood the most of the part but How can I unzip this?
so you just follow each block pointing to a block that holds the length of pointing blocks inside another table which will be followed by the pointing blocks following the structure that I explain earlier
D
Quick question: How doI add two vectors into athird using std::transform? For example: v1{1,2,3}, v2{3,2,1} and after std::transform v3={4,4,4}.
Anonymous
Guys because in the books to avoid are those of Deitel
The
Can I share a project here for feedback?
The
https://github.com/MichaelDim02/lykan
Anonymous
transform(v1.begin(), v1.end(), v2.begin(), back_inserter(v3), [](auto i, auto j){i+j;});
Hussein
ax^2 + bx + c = 0
Hussein
this the mathmatical formula
Iwan
C Program to Find the Roots of a Quadratic Equation https://www.programiz.com/c-programming/examples/quadratic-roots
Hussein
you just need to apply the formula that is tought in high school and you will get an answer right away
Maverick
hey . sorry I ask for a good and simple frame work for c++
Hussein
solve_equ( double a , double b , double c ) { return ( -b * pow( pow( b , 2 ) - 4 * a * c , 0.5) ) / 2 * a }
Hussein
Maverick
a framework for what kind of programs?
mobile application and games
Hussein
mobile application and games
Qt framework is quit good because it’s cross platform