Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Arduino: float mit 2 Kommastellen anzeigen

15.04.2020 (👁4744)


 

Problem:

bei einer Arduino Berechnung einer float Variable (Fließzahl, Kommawert) wird das Ergebnis immer ohne Nachkommastellen berechnet.

Die Berechung varFloat=1000/myFloat1  ergibt immer 0,00   

Lösung:

Man muss bei Rechenoperationen die festen Zahlen mit einem Punkt als Float angeben.

Beispiel: anstatt 1000 gibt man 1000.0 an

OK:

Output is 0.75 MHz

  float frequency= float1000.0 / nsPulswidth );

 

 

 

False:

Output is 0.00 MHz

  float frequency= float1000 / nsPulswidth );

 

 

Arduino ESP32