1
1

15の割り算で遊ぶ(0..256)

Last updated at Posted at 2024-07-31

x 過去ログを見よ
x arduino unoでは、予定は、未定

結果

o_coq267.jpg

プログラム



#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int sa[] = {
    //0123456789012345
    0b0000000000000001,
    0b0000000000000011,
    0b0000000000000111,
    0b0000000000001111,
    0b0000000000011111,
    0b0000000000111111,
    0b0000000001111111,
    0b0000000011111111,
    0b0000000111111111,
    0b0000001111111111,
    0b0000011111111111,
    0b0000111111111111,
    0b0001111111111111,
    0b0011111111111111,
    0b0111111111111111,
    0b1111111111111111,
    0b0000000000000000
    };//sa
    
    printf("\n\nSTART\n\n");
    
    int x = 60;
    int y;
    int a;

    y = x >> 4;

    a = sa[y];
    a = a << (x & 0x0f);
    a = a & 0x8000;
    a = a >> 15;
    a = a + ((x + 1) >> 8);
    y = y + a;
    
    
    printf("(%d)/(15)=(%d)\n",x,y);
 
}//main






START

(60)/(15)=(4)


1
1
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
1