Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - eric

Pages: [1]
1
QB64 Discussion / _SHR bug with sign bit of _UNSIGNED _INTEGER64
« on: December 03, 2019, 06:20:30 pm »
Hello,

I use qb64 to test some algorithms on integers when i got a strange garbage.

So, i try :

Code: QB64: [Select]
  1.  
  2. n = &H0100000000000000
  3.  
  4. PRINT , HEX$(n)
  5. n = _SHL(n, 7)     'shift 1 to sign bit left most
  6. PRINT , HEX$(n)
  7. n = _SHR(n, 7)     'revert to first position
  8. PRINT , HEX$(n)
  9.  
  10. m~&& = &H0100000000000000
  11. PRINT , HEX$(m~&&)
  12. m~&& = _SHL(m~&&, 7)
  13. PRINT , HEX$(m~&&)
  14. m~&& = _SHR(m~&&, 7)
  15. PRINT , HEX$(m~&&)
  16.  

both display result as :

     100000000000000
     8000000000000000
     FF00000000000000


I think _SHR is not shifting but expanding the "sign" bit to the right.

The last print is the negative of the first.

Is it a solution ?

Thanks.


Pages: [1]