SHARE
TWEET

Untitled

a guest Sep 15th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // based on a couple of StackOverflow answers
  2. #include <QCoreApplication>
  3.  
  4. #include <QtDebug>
  5.  
  6. qint32 sign_extend_24_32(qint32 x) {
  7.   const int bits = 24;
  8.   qint32 m = 1u << (bits - 1);
  9.   return (x ^ m) - m;
  10. }
  11.  
  12. int main(int argc, char *argv[]) {
  13.   QCoreApplication a(argc, argv);
  14.  
  15.   qint32 i = 262000;
  16.  
  17.   qint32 j = i & 0xFFFFFF;
  18.  
  19.   qint32 k = sign_extend_24_32(j);
  20.  
  21.   qDebug() << i << j << k;
  22.  
  23.   return a.exec();
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top