DataType

# UInt16

<div class="rst-class">

forsearch

</div>

DataType

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

## Description

Used to store unsigned 16-bit integer values. The default value is 0. Generally you will use the Integer data type (equivalent to `Int32</api/data_types/additional_types/int32>` on 32-bit apps or `Int64</api/data_types/additional_types/int64>` on 64-bit apps) or `UInteger</api/data_types/additional_types/uinteger>` (equivalent to `UInt32</api/data_types/additional_types/uint32>` on 32-bit apps or `UInt64</api/data_types/additional_types/uint64>` on 64-bit apps). This size-specific integer data type is available for use with external OS APIs.

## Notes

<span class="title-ref">UInt16</span> values can range from 0 to 65,535 and use 2 bytes.

All integers on Android are 64-bit integers.

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

### Comparing a <span class="title-ref">UInt16</span> to a literal or constant

The type of a numeric literal or constant that is a whole number is the same `integer</api/data_types/integer>` type as the architecture of the platform for which you are building. That means that if you are building for 64 bit, literals and constants will be 64 bit `integers</api/data_types/integer>`.

Therefore to correctly compare them, use `CType</api/language/ctype>` to cast the literal to a <span class="title-ref">UInt16</span>.

In this example the variable Distance is a \`UInt16\`:

``` xojo
If Distance = CType(0, UInt16) Then
  MessageBox("You have arrived.")
End If
```

## Compatibility

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

<div class="seealso">

`UInteger</api/data_types/additional_types/uinteger>`, `UInt8</api/data_types/additional_types/uint8>`, `UInt32</api/data_types/additional_types/uint32>` and `UInt64</api/data_types/additional_types/uint64>` data types.

</div>
