Questions tagged [integer-arithmetic]

Anything related to integer arithmetic, i.e. arithmetic operations on integer numbers. This is mostly relevant for languages which represent integer numbers with specific data-types (e.g. `int` or `long` in C, C++ or Java).

Anything related to integer arithmetic, i.e. arithmetic operations on integer numbers. This is mostly relevant for languages which represent integer numbers with specific data-types (e.g. int or long in C, C++ or Java).

452 questions
-1
votes
1 answer

8086 assembly language unsigned interpretation

I have to write a program in 8086 assembly that calculates this: (a+b*c+2/c)/(2+a)+e where a,b - byte c - word e - doubleword, in unsigned interpretation. So far I have this: assume cs:code,ds:data data segment a db 4 b db 2 c dw…
Boolean
  • 27
  • 6
-1
votes
2 answers

Bit-wise operations to implement logical shift to the right

So I am trying to solve this home assignment and I have been stuck with this one particular problem for a couple of hours and can't figure it out. I feel like I am so close! But then i change something in the code and something else isn't…
drleifz
  • 189
  • 3
  • 12
-1
votes
1 answer

Unsigned integer arithmetic warnings

I do apologize if this question has been answered somewhere else, but I've searched, and have not yet found an answer... I get the following warning when compiling the code below: warning: conversion to 'short unsigned int' from 'int' may alter its…
-1
votes
2 answers

Why doesn't this arithemtic operation work in java?

I was interested to see a weird error when performing the following: int width = 300; int var1 = width/3; int var2 = width * 1/3; int var3 = width * 2/3; int var4 = width*(1/3); int var5 = width * (int)(1/3); int var6 =…
ProfessionalAmateur
  • 4,447
  • 9
  • 46
  • 63
-1
votes
1 answer

Data decimal to Binary

Convert X10 to Binary X2 ; You MUST determine and state exactly how many bits are necessary for the representation of X10 in binary. Round up the value for the number of bits necessary to represent X2 to the nearest multiple of 4 and express X2 in…
Mohamed
  • 29
  • 4
-2
votes
1 answer

I was doing a code for , "Count Digits " , Evenly divides means whether N is divisible by a digit i.e. leaves a remainder 0 when divided

#include using namespace std; int main() { int n,m,z; cout<<"enter n: "; cin>>n; z=n; int count=0; while(n>0){ m = n % 10; if(z%m == 0){ count++; } n=n/10; } cout<
-2
votes
1 answer

How is cout << different from cout << ?

I'm trying to solve this problem: https://www.codechef.com/FEB222C/problems/WCC I've solved this problem and have successfully submitted the solution, but I'm getting 'WRONG ANSWER' error in an alternate approach in one test case: My successful…
-2
votes
2 answers

right shift bool in C++

In given code, a bool has been passed on to foo as shown in mainFunc. I am not sure if e >> 24 is a right thing to do in foo. I believe this will only give garbage values. void foo(bool e){ int a; bool s; e = e >> 24; ... } void…
-2
votes
1 answer

Intercepting Arithmetic Operations in C program

Is there a way that we can call user defined function when we are calling arithmetic operator in a C program just like operator overloading in C++. using GNU GCC Compiler? Simply, I have a function add(), and in my C program I have arithmetic…
Rakesh
  • 133
  • 1
  • 8
-2
votes
3 answers

How to efficiently compute large powers of 2?

I'm trying to calculate, for 0 < n ≤ 10⁹, the value of re=(2^n)%1000000007 I wrote this code: int main() { int n,i,re=1; scanf("%d",&n); for(i=0; n>i; i++) re=(2*re)%1000000007; printf("%d",re); } When n is 10⁹, my code takes too…
Mostafa
  • 1
  • 4
-2
votes
2 answers

8051 16 bit addition/multiplication result 16 bit instead of 32 bit

I have a problem. In this program the variable x should be set to 0x10000 but in both operations the result is 0. This is not the main program but a test to find the reason for the error. I am currently making a 64 bit multiplier with hex input. I…
-2
votes
2 answers

Multi-Statement Arithmetic in c++

This may have been asked already, but I was unable to find it on this forum. I had a general question about integer arithmetic in c++ when doing arithmetic on large integers. unsigned int value = 500000; value = (value * value) % 99; The correct…
Feek
  • 297
  • 3
  • 15
-2
votes
2 answers

Notepad can not find symbol for Average, max, min, etc

First, this is a homework assignment. I am supposed to create a program using a switch command. It asks the user to input 3 integers, then input an integer of 1-5 for the five cases average, max, min, total, and exit. I have pretty much completed…
-2
votes
2 answers

How to pop String data into an integer container to perform arithmetic

Im having trouble extracting the String data from a stack and converting it to int to perform arithmetic, it keeps telling me that i cannot cast a string to an int and vice versa, however i don't know any other alternative methods. this is the code…
-3
votes
1 answer

What are hybrid-integer?

what are Hybrid Integers mentioned in this problem and what are applications of Hybrid Integers?