Variable als float in map [erledigt]


hallo,
ich habe:

int percentm1pdruck;
float pdruck;
float m1pdruck;
float ergebnis;


pdruck = 1008,74;
m1pdruck = 1008,65;

dann wird,

percentm1pdruck = map((m1pdruck *= 10),-50,50,0,150);

ausgeführt.

danach:

ergebnis = pdruck - m1pdruck;
tft.print(ergebnis,1);

das berechnete ergebnis ist 0,09.

ausgegeben wird aber 0,9.

ist es richtig, das "map" der variable "m1pdruck" einen neuen wert zuweist?
oder nutze ich in "map" einen falschen syntax?

gruß und dank
andreas

hallo andreas,
ist es von dir gewollt, dass, bevor die map-funktion aufgerufen wird, m1pdruck nicht nur mal 10 genommen wird, sondern dieser neue wert auch in der variable gespeichert wird?
denn
code: [select]
m1pdruck *= 10
ist nicht das gleiche wie
code: [select]
m1pdruck * 10

dadurch könnte deine abweichung von 1/10 herkommen.

lg programmer


Arduino Forum > International > Deutsch (Moderator: uwefed) > Variable als float in map [erledigt]


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'