
| Re: formatierte Ausgabe über hwcom Kategorie: Programmierung (von nitraM - 15.04.2010 10:04) | ||
| Als Antwort auf Re: formatierte Ausgabe über hwcom von ChristianS - 14.04.2010 23:05 | ||
| ||
|
Hallo Christian ich würd es so machen: function Temp_ausgabe(int temp) {if temp < 0 {hwcom.print("-"); } temp = math.abs(temp); // Betrag bilden (Wert ist ab jetzt immer positiv) if temp < 1000 // eine Null voranstellen? 1000=>10,00 999=>09,99 {hwcom.print("0"); } hwcom.num(temp / 100); // Vorkommawert hwcom.print(","); temp = temp % 100; if temp < 10 // eine Null voranstellen? {hwcom.print("0"); } hwcom.num(temp); // Nachkommawert hwcom.print("°C"); hwcom.ret(); .... } nitraM | ||
Antwort schreiben Antworten: | ||