Padded Binary String
#11
I don't like those negative numbers!
Code: (Select All)
Do
    Input "What ever number "; whatevernumber
    bn$ = _Bin$(whatevernumber) 'the binary string returned by _BIN$
    dw = 8 'desired field width

    If Len(bn$) >= dw Then
        Print bn$ 'number already in desired width or even longer
    Else
        Print Right$(String$(dw, "0") + bn$, dw) 'left padded with zeros
    End If
    Print "Back to decimal? "; Val("&B" + bn$)
Loop Until whatevernumber = 0
[Image: Dont-trust-those-negative-numbers.png]
b = b + ...
Reply


Messages In This Thread
Padded Binary String - by James D Jarvis - 08-25-2022, 12:35 AM
RE: Padded Binary String - by mnrvovrfc - 08-25-2022, 01:45 AM
RE: Padded Binary String - by James D Jarvis - 08-25-2022, 01:50 AM
RE: Padded Binary String - by mnrvovrfc - 08-25-2022, 01:56 AM
RE: Padded Binary String - by SMcNeill - 08-25-2022, 04:27 AM
RE: Padded Binary String - by Pete - 08-25-2022, 04:53 AM
RE: Padded Binary String - by SMcNeill - 08-25-2022, 04:59 AM
RE: Padded Binary String - by Pete - 08-25-2022, 06:12 AM
RE: Padded Binary String - by RhoSigma - 08-25-2022, 08:19 AM
RE: Padded Binary String - by mnrvovrfc - 08-25-2022, 03:12 PM
RE: Padded Binary String - by bplus - 08-25-2022, 04:17 PM
RE: Padded Binary String - by bplus - 08-25-2022, 04:21 PM
RE: Padded Binary String - by SMcNeill - 08-25-2022, 06:18 PM
RE: Padded Binary String - by RhoSigma - 08-25-2022, 04:36 PM
RE: Padded Binary String - by SMcNeill - 08-25-2022, 04:30 PM
RE: Padded Binary String - by bplus - 08-25-2022, 07:51 PM
RE: Padded Binary String - by SMcNeill - 08-25-2022, 08:03 PM



Users browsing this thread: 9 Guest(s)