Basic Univers
Procedure.s ByteToBin(b.b)
  Protected s.s, i.b
  
  s = "00000000"
  For i = 0 To 7
    If b & 1 << i
      PokeB(@s +(7 - i), Asc("1"))
    EndIf
  Next
  ; Debug s
  ProcedureReturn s

EndProcedure


Procedure.s LongToBin(l.l)
  Protected s.s, i.w
  
  s = "00000000000000000000000000000000"
  For i = 0 To 31
    If l & 1 << i
      PokeB(@s +(31 - i), Asc("1"))
    EndIf
  Next
  ; Debug s
  ProcedureReturn s

EndProcedure



Procedure.s FloatToBin(f.f)
  ProcedureReturn LongToBin(PeekL(@f))
EndProcedure


Procedure.s Debug_Float32(Address.f)
  Sign.l = PeekL(@Address) & $80000000
  If Sign : Sign = - 1 : Else : Sign = 1 : EndIf
  Exponant.l = PeekL(@Address) & $07F80000
  Exponant.l = Exponant >> 23
  Mantissa.l = PeekL(@Address) & $007FFFFF
  Mantissa_Copy.l = Mantissa
  ProcedureReturn RSet(Hex(PeekL(@Address)), 8, "0") + " Sign : " + Str(Sign) + " Exponant : " +  RSet(Hex(Exponant), 2, "0") + " Mantissa : " + RSet(Hex(Mantissa), 6, "0")
EndProcedure


; ***********************
; *    Partie Long !!!  *
; ***********************



a.l = 32767

Debug "Conversion de " + Str(a)
s.s
For i = 0 To 3
  s = ByteToBin(PeekB(@a + i)) + s
Next i

Debug s

Debug LongToBin(a)


; ***********************
; *   Partie Float !!!  *
; ***********************

Debug " "
Debug "Conversion Float to Bin"


fValue.f
fValue = 3.125
Debug FloatToBin(fValue)
; fValue = 0.0 : Debug StrF(fValue, 10) + "   " + FloatToBin(fValue)
; fValue = 1.0 : Debug StrF(fValue, 10) + "   " + FloatToBin(fValue)
; fValue = 2.0 : Debug StrF(fValue, 10) + "   " + FloatToBin(fValue)
; fValue = #PI : Debug StrF(fValue, 10) + "   " + FloatToBin(fValue)
; fValue = -3.14159265 : Debug StrF(fValue, 10) + "   " + FloatToBin(fValue)
; fValue = 31.4159265 : Debug StrF(fValue, 10) + "   " + FloatToBin(fValue)
; fValue = 31415.9265 : Debug StrF(fValue, 10) + "   " + FloatToBin(fValue)