Bin$
ResultString$ = Bin$(ValueToConvert)
 
Parameters:

    ValueToConvert = The value you wish to translate to a binary string
Returns:

    ResultString$
 

      For those familiar with binary number systems, Bin$() is a handy function that will take an integer value and convert it to a binary formatted string.



FACTS


      * The created string will be in the form "%00000000000000000000000000000000"

      * Each bit is represented with either a 0 (off) or 1 (on) character.

      * PlayBASIC compiler supports binary literals, so you insert such values into your source code directly.





Mini Tutorial:


      How to display the binary representation of integer values.

  
  
; Display 255 in binary
  Print Bin$(255)
  
; Display the values 0 through 10 in binary.
  For lp=0 To 10
     Print Str$(lp)+" )="+Bin$(lp)
  Next
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  




This example would output.

  
  %00000000000000000000000011111111
  
  0)=%00000000000000000000000000000000
  1)=%00000000000000000000000000000001
  2)=%00000000000000000000000000000010
  3)=%00000000000000000000000000000011
  4)=%00000000000000000000000000000100
  5)=%00000000000000000000000000000101
  6)=%00000000000000000000000000000110
  7)=%00000000000000000000000000000111
  8)=%00000000000000000000000000001000
  9)=%00000000000000000000000000001001
  10)=%00000000000000000000000000001010
  


 
Example Source: Download This Example
; -------------------------------------------------
; Bin$ EXAMPLE
; -------------------------------------------------
  
  
; Display the Binary String representation of the integer value 15
  Print Bin$(15)
  
; Display the Binary String representation of the integer value 255
  Print Bin$(255)
  
; Display the Binary String representation of the integer value 65535
  Print Bin$(65535)
  
  
; Show Us the Screen And Wait For Key Input before ending
  Sync
  WaitKey
  
 
Related Info: Hex$ | Literals | Str$ | Val :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com