Method

# Bin

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Returns the binary version of the number passed as a `string</api/data_types/string>`.

## Usage

``` xojo
result = Bin(value)
```

| Part   | Type                               | Description                           |
|--------|------------------------------------|---------------------------------------|
| result | `String</api/data_types/string>`   | *value* converted to binary.          |
| value  | `Integer</api/data_types/integer>` | The number to be converted to binary. |

## Notes

If the value is not a whole number, the decimal part will be truncated.

You can specify binary, hex, or octal numbers by preceding the number with the & symbol and the letter that indicates the number base. The letter b indicates binary, h indicates hex, and o indicates octal.

## Sample code

Below are examples of various numbers converted to binary:

``` xojo
Var binVersion As String
binVersion = Bin(15) ' returns "1111"
binVersion = Bin(15.5) ' returns "1111"
binVersion = Bin(75) ' returns "1001011"
binVersion = Bin(&hF) ' returns "1111"
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`&b</api/language/literals/b>`, `&h</api/language/literals/h>`, `&o</api/language/literals/o>` literals; `Hex</api/text/hex>`, `Oct</api/math/oct>`, `Integer.FromBinary<integer.frombinary>`, `Integer.ToBinary<integer.tobinary>` functions

</div>
