Questions tagged [arithmetic]
The arithmetic tag has no summary.
30 questions
-4votes
1answer
176views
if I write 16 bit floating point number representation of 2044 and 2045.5 it's seems like the same, which is 0 1001001 11111111 why is that? [closed]
floating point representations## exponent == 7 bits ,mantissa == 8 bits 2044 = 0 1001001 11111111 2045.5 = 0 1001001 11111111 why is this happening?? what is the error? Is anything wrong with the ...
8votes
7answers
9kviews
What is the size of the number 65535 in bytes? [closed]
As I got to know there are 256 possible combinations to get for 1 byte. If I understand it correctly, it should mean that you can display any number out of numbers 0-255 and this very number would use ...
4votes
1answer
4kviews
Semantics of simulating a 64bit integer with two 32bit integers (hi, lo)
I am working in a system which only supports 32bit integers, in order to have a 64bit (unsigned) integer I decided to simply use two 32bit integers with one being the upper 32 bits (hi), and the other ...
1vote
7answers
740views
Is the sum or subtraction of two positive machine numbers exact?
If you have two positive numbers that can be represented exactly by the finite arithmetic of your computer, that is, two machine numbers, if you perform their sum or subtraction with perfect ...
-2votes
2answers
5kviews
Why does Integer.MIN_VALUE - Integer.MAX_VALUE equals to 1 in Java?
If you run the statement: System .out.println( (Integer.MIN_VALUE)-(Integer .MAX_VALUE )); In java it returns 1 as the answer. Is this because Java just considers those values as 32bit integers ...
2votes
2answers
211views
Is writing arithmetic functions to allow "type coercion" a good idea?
Let's say I want to write a function to compute factorials of nonnegative integers. I could write something like this: fact :: Num a => Int -> a fact n = fromInteger(product [1..n]) (Let's not ...
-1votes
2answers
155views
Describe a slope (N/M), approximately as small number of fractions (n/m)
What algorithm can I use to describe a specified gradient (N/M) approximately as the sum of a set of rational fractions { (n1/m1) + (n2/m2) … } ? Design constraints: The algorithm takes as input (N, ...
0votes
1answer
594views
For learning purposes, how should I set about implementing an arbitrary precision library in C or C++?
I know I am reinventing the wheel. But I'm really interested in implementing arbitrary precision numbers (integers, rationals, complex, etc) in C or C++ and their algorithms. Please be patient. My ...
2votes
5answers
471views
Shortening a boolean AND with third operand
I'm trying to calculate the sum of 2 bits using basic binary arithmetic and currently, I'm doing this: function Add(bool a, bool b, bool carry) { return { Result: a ^ b ^ carry, ...
2votes
2answers
5kviews
Understanding of the Carry Flag Bit
Intel 8085: In my textbook it is said: "Carry Flag - this flag is the carry out from the MSB of the A-register. CY is set after an ADD instruction if carry out was generated from the A-register." I ...
3votes
1answer
4kviews
Difficulties with Two's complement in Assembly
Everything discussed here will refer to Intel 8085 (8-bit architecture). When using two's complement number "conversion" : 1.) If we take SBI 0F (subtraction) for example; immediate value 0F(hex) or ...
-1votes
1answer
105views
Multiprecision Arithmetic; The Carry Flag
Intel 8085: I'm having big troubles understanding addition or subtraction with more than 16-bit numbers in Intel 8085: 1.) If I execute ADC M instruction then this should happen: (A)<--(A)+((H)(L))...
4votes
4answers
2kviews
Why are arbitrary-precision decimals used over rational numbers in practice?
The basic arithmetic a computer chip can do only works on numbers(integers or floating point) of a fixed size. There are many algorithms that could be extended to work on numbers of arbitrary size (...
-1votes
1answer
90views
How do two (programming) methods for capping daily rep stack up?
I wrote a supersuccessful answer to a question on an SE site that got (at least) 21 upvotes in a 24-hour period. In theory, I should have gotten 210 rep points, but there is a daily reputation limit ...
0votes
1answer
454views
Combine sequences of numbers with "variable bitlengths" into short unique strings
It is not unlikely that what I want to do is not possible, but it doesn't hurt to ask. Imagine a set of lists, each containing positive integers (in my case, a list always consists of four integers, ...