0
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?

More than 1 year has passed since last update.

10の割り算 割られる数が1000ぐらいまで正しい

Last updated at Posted at 2023-11-25

xコメントも見てください。

10の割り算 割られる数が1000ぐらいまで正しい

目的
温度センサー等の値から数値の文字列に
変換したい。

原理

(x * 204.8)/2048 = x * 1/10

(x * 205 )/2048 = だいたい x * 1/10

例 温度が27度の時

( 27 * 205 ) >> 11 = 2 (小数点以下切り捨て)

オンラインコンパイラ


#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int al;
    
    al=27;
    al=(al*205)>>11;
    printf("%d\n",al);
    
}


2

0
0
6

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
0
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?