arithmetic

Bit Level Manipulation & Arithmetic Functions (In C)

Hey everybody. I am learning bit wise operation and arithmetic operations in C but I am a bit confused about some of it. I am working through some of the review questions in my book but the book only has answers for the odd number questions so I would like to pose some questions for you guys so I can tell if I am on the right track. Than...

xslt - subtracting days

Hi, Is it possible with xslt to take a date field and subtract N number of days from it? If so, can you please provide me an example? Thanks in advance for your help! Matt ...

java arithmetic

why this code returns wrong value? int i=Integer.MAX_VALUE+1; long l=Integer.MAX_VALUE+1; System.out.println(l); System.out.println(i); ...

Generic Arithmetic in Java

Hello all, I have a filter class wherein the user must declare the type (e.g. Filter<Double>, Filter<Float> etc). The class then implements a moving average filter so objects within the class must be added. My question is how to do this? I'm sorry if the answer is simple but I've muddled myself up by thinking about it too much I think :...

How can I know whether one number is a multiple of other number?

I tried using 6%2, but its always giving the value as 2 and not 0. Why and how can I get a solution to this? ...

How to read/write full 32 or 64 bits of an int or bigint bitmasked field in TSQL.

Setting the 32nd and 64th bits is tricky. 32-bit Solution: I got it to work for 32-bit fields. The trick is to cast the return value of the POWER function to binary(4) before casting it to int. If you try to cast directly to int, without first casting to binary(4), you will get an arithmetic overflow exception when operating on the 3...

signed bitwise arithmetic in Python

I got stuck with the following Python code >>> a = 0xff >>> b = 1 << 8 >>> ~a & ~b -512 Why is it -512? In binary notation it should look like this: a 0 1111 1111 -> 255 b 01 0000 0000 -> 256 ~a 1 0000 0000 -> -256 ~b 10 1111 1111 -> -257 ~a&~b 00 0000 0000 -> 0 I expected 0 as with signed int...

Need code for addition of 2 numbers

I am having the numbers follows taken as strings My actual number is 1234567890123456789 from this i have to separate it as s=12 s1=6789 s3=3456789012345 remaining as i said I would like to add as follows 1+3, 2+4, 6+5, 7+6, 8+7, 9+8 such that the output should be as follows 4613579012345 Any help please ...

Wrapping my head around hardware representations of numbers: a hypothetical two's complement question

This is a super naive question (I know), but I think that it will make for a good jumping off point into considering how the basic instruction set of a CPU actually gets carried out: In a two's complement system, you cannot invert the sign of the most negative number that your implementation can represent. The theoretical reason for thi...