Forum: Digitale Signalverarbeitung / DSP / Machine Learning Fract16 auf ASCII


Announcement: there is an English version of this forum on EmbDev.net. Posts you create there will be displayed on Mikrocontroller.net and EmbDev.net.
von Herbert (Gast)


Lesenswert?

Hallo Leute!
Ich habe da eine Frage: Wie mache ich es am besten, wenn ich einen 
Fract16-Datentyp als ASCII-Zeichen repräsentieren will?
Bsp: fract16 x
x = 0x0001 (0.000031) ---> "0.000031"

Mfg
von Alex (Gast)


Lesenswert?

fract16 temp = 0x0001;
printf("%.7f\n", (temp&(1<<16)) ? (expr1) : (expr2));

expr1: -(float)temp/(float)32768;
expr2:  (float)temp/(float)32768;

Ist aber nicht performant :)
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.