Взять всё, да и поделить!

 


n=1
d=7
r$=""
Repeat
  If n<d
    If r$=""
      r$="0."
    EndIf
    n=n*10
    While n<d
      r$+"0"
;   If Len(r$)=1
;     r$+"."
;   EndIf
    n=n*10
  Wend
EndIf
  res=Int(n/d)
  r$+Str(res)
;   If Len(r$)=1
;     r$+"."
;   EndIf
  n=n-res*d
  If Len(r$)>=80
    Break
  EndIf
Until n=0
  Debug r$

Дополнение. Забыл про деление на 0, программа зацикливается

n=392*0
d=4
r$=""

If n
Repeat
  If n<d
    If r$=""
      r$="0."
    EndIf
    n=n*10
    While n<d
      r$+"0"
;   If Len(r$)=1
;     r$+"."
;   EndIf
    n=n*10
  Wend
EndIf
  res=Int(n/d)
  r$+Str(res)

;   If Len(r$)=1
;     r$+"."
;   EndIf

  n=n-res*d
  If Len(r$)>=80
    Break
  EndIf
Until n=0

Else
  r$="0"
EndIf

  Debug r$

Дополнение 08-08-02023. Снова ошибки:( 
n=-1
d=-4

r$=""
m$=""

If d
  If n<0
    n=-n
    If d>0
      m$="-"
    Else
      d=-d
    EndIf
  Else
    If d<0
      d=-d
      m$="-"
    EndIf
  EndIf
  
  If n
    Repeat
      If n<d
        If r$=""
          r$="0."
        EndIf
        n=n*10
        While n<d
          r$+"0"
          n=n*10
        Wend
      EndIf
      res=Int(n/d)
      r$+Str(res)
      n=n-res*d
      If Len(r$)>=80
        Break
      EndIf
    Until n=0
    
  Else
    r$="0"
  EndIf
Else
  r$="unable to divide by zero"
EndIf

Debug m$+r$

Комментарии