Padded Binary String
#9
Code: (Select All)
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
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: 10 Guest(s)