1
vote
1answer
38 views

What's a more optimal native C-language algorithm to set bit $k$? [closed]

Let $n$ be an integer (for example an unsigned int which is usually 32- or 64-bits), let the number of bits be $|n|$. Let $0 \leq k \lt|n|$. I usually do: ...
1
vote
3answers
33 views

Generate numbers that add up to X

I have isolated the algorithm of a keygenme, but I am running into difficulty with creating the keygen. The key has a length of seven digits, and the sum of each of the digits in the key must be ...
1
vote
0answers
32 views

Generate Max Value Expression

How to insert * AND + OPERATORS between a given set of integers so that the expression evaluates to the max possible value if Set is [3,4,5,6,-2] it should give 3*4*5*6+-2 and also note that * gets ...
1
vote
1answer
79 views

Signed binary arithmetic

I'm having trouble with a fairly simply concept, signed binary arithmetic. I know how to do 1's and 2's complement, convert from binary, decimal, octal, and hex, multiply and add bytes and bits, but ...
1
vote
1answer
127 views

Euclidean Division to avoid need for floating point arithmetic

In simple terms (that Google has been unable to provide the answer), is there an approach to dividing a whole integer by a quotient & remainder? As a specific example, ...
0
votes
0answers
308 views

Square root using simple arithmetic shift, inversion etc

Suppose we have a function which is sampled by a sampling time 10ms. This function comes in to the computer, then this computer should calculate square root (for every sampling time) from that ...
2
votes
0answers
127 views

1/3+2/3 in double precision

When I add 1/3 and 2/3 in double precision, I ended up with $1.\boxed{111\ldots1}1\times2^{-1}$, where the boxed part is the 52-bit mantissa. By the rounding to even rule, I should round it up, right? ...
0
votes
2answers
597 views

Do calculators have floating point error?

As a programmer, we have been told about floating points errors on computer. Do Calculators have floating point error too? Example. ...
1
vote
2answers
148 views

Using base-2 numbers: $(1010001)_{2}/(11)_{2}=?$

I wanna solve this simple equation using base-2 number system. $(1010001)_{2}/(11)_{2}=?$ I can't remember how to do that, normally I would start with $101/11$ but what should I do this base-2 ...
0
votes
2answers
462 views

bitwise operations

so my question is what is the order of operations for bitwise operators << & | and also to see if my logic is right with the problem below (x03 << x08)+ x00 = 300 ...