Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Func _DecimalToBinary($D, $N=100)
- Local $S = ($D < 0)
- $D = Abs($D)
- Local $F = $D - Int($D)
- $D = Int($D)
- Local $B = ""
- Do
- $B = Mod($D, 2) & $B
- $D = Int($D / 2)
- Until $D = 0
- Local $i
- If ($F > 0) Then
- $B &= "."
- For $i = 1 To $N
- $F *= 2
- $B &= Int($F)
- $F -= Int($F)
- If ($F = 0) Then ExitLoop
- Next
- EndIf
- If $S Then
- Return "-" & $B
- EndIf
- Return $B
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement