jo, habs gerade mal durchsimuliert...

Simulator hat in den Locals eine glatte 0, gibt aber selber eine -0.0 als Printout aus.

ist irgendwie nicht konsistent....

jedenfalls lässt sich auf diese -0.0 checken - zumindest solang nichts an dieser Round-Funktion verändert wird.

Ein weiterer Fehler war ausserdem noch drin - wenn der Nachkommastring kleiner war, also der Nachkomma-Anteil ursprünglich führende Nullen hatte.

Ist jetzt gefixt und sieht so aus:

Code:
$regfile = "m128def.dat"
$crystal = 16000000
$framesize = 120                                           
$swstack = 120
$hwstack = 120
$baud = 57600
$sim

Declare Function Ausgabe(byval _x As Single , Byval _v As Byte , Byval _n As Byte) As String

Dim Ausgabe_string As String * 20
Dim Ausgabe_string_zeichen(21) As Byte At Ausgabe_string Overlay
Dim Zahl As Single : Zahl = -1

Do
   Print Zahl ; " rund " ; Ausgabe(zahl , 2 , 1)
   Zahl = Zahl + 0.01
Loop
End





Function Ausgabe(byval _x As Single , _v As Byte , _n As Byte) As String
'_v = Anzahl Vorkommastellen ; _n = Anzahl Nachkommastellen
Local _string As String * 15 : _string = ""
Local _laenge As Byte
Local _zaehler As Byte : _zaehler = 0
Local _faktor As Long : _faktor = 1
Local _nachkomma_string As String * 10
Local _vorkomma_string As String * 10
Local _anz_zeichen As Byte
Local _minus As Byte

    While _zaehler <> _n
       _faktor = _faktor * 10
       Incr _zaehler
    Wend
    'Print "IN:" ; _x ; "->";
    _x = _x * _faktor
    'Print "*fak:" ; _x ; "->";
    _x = Round(_x)
    'Print "rounded:" ; _x

    If _x >= 0 Or _x = -0.0 Then                            'bei x=0 springt der Simulator in Else-Zweig
          _minus = 0
       Else
          _minus = 1
    End If
    _x = Abs(_x)

    Ausgabe_string = Str(_x)
    _laenge = Len(ausgabe_string)
    _laenge = _laenge - 2
    Ausgabe_string = Left(ausgabe_string , _laenge)         '".0" abschneiden

    _laenge = Len(ausgabe_string)
    _anz_zeichen = _n
    While _laenge < _anz_zeichen
         Ausgabe_string = "0" + Ausgabe_string
         _laenge = Len(ausgabe_string)
    Wend
    _nachkomma_string = Right(ausgabe_string , _n)

    _anz_zeichen = _v + _n
    While _laenge < _anz_zeichen
         Ausgabe_string = "0" + Ausgabe_string
         _laenge = Len(ausgabe_string)
    Wend

    _vorkomma_string = Left(ausgabe_string , _v)

    If _minus = 1 Then _string = "-" Else _string = " "
    _string = _string + _vorkomma_string
    If _n > 0 Then
          _string = _string + ","
          _string = _string + _nachkomma_string
    End If

    Ausgabe = _string
End Function

mfG
BoGe-Ro