Linked Questions

104 votes
3 answers
54k views

As we know, signed integer overflow is undefined behavior. But there is something interesting in C++11 cstdint documentation: signed integer type with width of exactly 8, 16, 32 and 64 bits ...
Archie's user avatar
  • 6,921
2 votes
3 answers
22k views

I'm trying to implement a rotateRight by n function in C by only using bitwise operators. So far, I have settled on using this. y = x >> n z = x << (32 - n) g = y | z So take for ...
krb686's user avatar
  • 1,826
6 votes
4 answers
1k views

#include <limits.h> int main(){ int a = UINT_MAX; return 0; } I this UB or implementation defined? Links saying its UB https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/...
Dan's user avatar
  • 3,068
3 votes
9 answers
826 views

Here is my code #include<stdio.h> void main() { char ch = 129; printf("%d", ch); } I get the output as -127. What does it mean?
user avatar
-1 votes
3 answers
2k views

I had been learning C and came across topic called Cyclic Nature of Data Type in C. It is like example char c=125; c=c+10; printf("%d",c); The output is -121. the logic given was 125+1= 126 125+...
shashank's user avatar
  • 410
4 votes
2 answers
3k views

Suppose I have two long longs, a and b, that I need to multiply, then get the value mod k for some large k, such that a, b, and k are all in the range of long long but not of int. For simplicity, a, b ...
John Targaryen's user avatar
6 votes
3 answers
169 views

Here is the piece of code from GNU C reference manual Pg 74: If your code uses a signed loop index, make sure that the index cannot overflow, along with all signed expressions derived from the ...
Ankur Agarwal's user avatar
0 votes
2 answers
917 views

This is my prime number function and I have a problem. Why does it return 0 when I pass it 2147483647? int ft_is_prime(int nb) { if (nb<2) return (0); else if (nb==2) return (1); ...
Wanctin Jean-marc's user avatar
-1 votes
1 answer
722 views

What value will I get with this code for example, short int num = 32766 num + 5 = ? Maxium value for short int is 32767.
Markus Fürst's user avatar
1 vote
1 answer
556 views

I am implementing a game engine and am implementing two version of time: Real time Scaled time (for slow / fast motion effects) Real time fully implemented and works, but I am having serious ...
Christopher Barrios Agosto's user avatar
1 vote
1 answer
158 views

I'm still quite new to c++ and just experimenting with the language. I have recently created a 'tictactoe' game. I have created this simple looking function to get the users board position (from 1 ...
SzczureX's user avatar
2 votes
1 answer
75 views

I have executed this program on 32bit Windows 7 OS with Turbo C/C++ editor. #include<stdio.h> #include<conio.h> void main() { int a,b,c,d,e; clrscr(); a = 25000; b = ...
Rohit S's user avatar
  • 395
-3 votes
1 answer
81 views

I am confused a little bit as when I multiply an int variable by 10 and then divide it by 10 I thought the variable value should not be changed but I get a different result am I missing something or ...
Galal Ramzy's user avatar
-3 votes
1 answer
114 views

Here's the piece of code: int catalan(int n) { if (n<0){ return 0; } if (n<=1){ return 1; } int total = 0; for(int i=0;i<n;i++) { total += ...
Awakoto's user avatar
  • 13