Gadget Renesas

Linking Ideas and Electronics

がじぇるね工房

Using the function on GR-KURUMI, Floating point numbers vol.

GR-KURUMIの機能を使う 浮動小数点編

####

Let’s try to use floating point numbers

Login in web compiler and generate new project or re-open the project which you just built last time. Let's practice. Get ready Arduino pro mini to compare. Please refer to the code below.

image01

Above code works on Arduino IDE but can’t compile on WEB compiler.

The chart is the execution result on Arduino pro mini.
Found that it’s rounded off to three decimal places.

If two decimal place is effective, seems it’s no problem to show the result of arithmetic operation.

However, someone may seek more accuracy.
※ Even it doesn’t have practical use.

Please refer to the following code.

image02

Arduino IDE was not able to deal with %f in sprintf form. Such things will happen when using simplified printf version.

WEB compiler can deal with %f.

The result is in the data capture of Tera Term in the chart. On Arduino IDE, when you control the effective decimal place in floating point numbers by yourself, use dtostrf.
http://technical.ddo.jp/index.php?dtostrf()

MVP information

@chobichan

General hard engineer.. submitting his writing for technical magazine occasionally.
twitter account:
https://twitter.com/chobichan

Chobichan avatar

Follow him

All articles from @chobichan

share