Questions tagged [arithmetic]
The arithmetic tag has no summary.
30 questions
-4
votes
1
answer
196
views
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 ...
8
votes
7
answers
10k
views
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 ...
4
votes
1
answer
5k
views
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 ...
1
vote
7
answers
782
views
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 ...
-2
votes
2
answers
5k
views
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 ...
2
votes
2
answers
220
views
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 ...
-1
votes
2
answers
167
views
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, ...
0
votes
1
answer
646
views
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 ...
2
votes
5
answers
500
views
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,
...
2
votes
2
answers
5k
views
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 ...
3
votes
1
answer
4k
views
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 ...
-1
votes
1
answer
118
views
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))...
4
votes
4
answers
3k
views
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 (...
-1
votes
1
answer
99
views
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 ...
0
votes
1
answer
468
views
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, ...