Questions tagged [integer-math]
4 questions
                    
                    21
                    
            votes
                
                2 answers
            
        python 32-bit and 64-bit integer math with intentional overflow
What's the best way to do integer math in 32- and 64-bit, so that overflow happens like it does in C?
e.g. (65536*65536+1)*(65536*65536+1) should be 0x0000000200000001 in 64-bit math, and not its exact value (non-overflowing) 0x10000000200000001.
        
        Jason S
        
- 184,598
 - 164
 - 608
 - 970
 
                    1
                    
            vote
                
                1 answer
            
        Effective way to calc without float, C
I need to do a math to convert a 16-bit value received from sensor to real relative humidity value. It's calculated with following formula:
Given this in floating point math that would be:
uint16_t buf = 0x7C80; // Example
float rh =…
        
        NStorm
        
- 140
 - 7
 
                    0
                    
            votes
                
                0 answers
            
        How can I calculate x^y in assembly language?
This is what  I have got so far. This is 32-bit multiplication is a 32 bit. I would like to improve this code and calculate x^y. I would really appreciate it if you give me a sample code. This code use  sub-rutine 
ex) 4^3=64
  ORG 10
LA, LDA AH
   …
        
        Jenny I
        
- 91
 - 1
 - 2
 - 7
 
                    -6
                    
            votes
                
                1 answer
            
        Sorting integers in C with only basic math functions
Im attempting to write a program in C
Given an input of three unique, non negative int type numbers, the program should sort them and output them sorted in an increasing order. For this program, only the basic mathematical constructs are permitted.…
        
        Sean
        
- 33
 - 1