いろいろ注意
- 過去ログを見よ
- arduinoでの予定は、未定
- 誰得、俺得
- stm32系とesp32系は、printf文が使えるはず?
目的
- 主に温度センサーのバイナリー値を変換して表示する
プログラム
- オンラインコンパイラpaiza
#include <stdlib.h> // abs用
#include <iostream>
using namespace std;
int main(void){
// Your code here!
int tmp; //10進固定小数点2桁(元を100倍した数)
//tmp = 2525;
//tmp = 25;
//tmp = 0;
//tmp = -25;
tmp = -2525;
//printf("%d\n",tmp); //debug
//負の数の時で0から-100の時の処理
if( (tmp < 0) & (tmp > (-100)) ){
printf("-0.%02d\n",abs(tmp%100));
} else {
printf("%d.%02d\n",tmp/100,abs(tmp%100));
}
}
-25.25