1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

正しく分割された2byteをshort (16bit)に戻して遊ぶ。(教科書的な内容)

Last updated at Posted at 2025-01-15

x M5NanoC6での予定は、未定

オンラインコンパイラ paiza



#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    short a;
    
    a = 0x04 * 256 + 0xD2; //1234
    
    printf("%d\n",a);
}



1234


おまけ(いろいろ説明すると長くなるが、なぜか上手くいく)



#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    short a;
    
    a = 0xff * 256 + 0xff; //1234
    
    printf("%d\n",a);
}



-1

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?