---
title: "Basic Types"
url: https://docs.zeroc.com/ice/3.8/slice/basic-types
language: js
docs_index: https://docs.zeroc.com/llms.txt
---

> For an index of every page, see [llms.txt](https://docs.zeroc.com/llms.txt).

# Basic Types

Programming language: JavaScript. Other languages: [C++](https://docs.zeroc.com/ice/3.8/slice/basic-types/cpp.md), [C#](https://docs.zeroc.com/ice/3.8/slice/basic-types/csharp.md), [Java](https://docs.zeroc.com/ice/3.8/slice/basic-types/java.md), [MATLAB](https://docs.zeroc.com/ice/3.8/slice/basic-types/matlab.md), [PHP](https://docs.zeroc.com/ice/3.8/slice/basic-types/php.md), [Python](https://docs.zeroc.com/ice/3.8/slice/basic-types/python.md), [Ruby](https://docs.zeroc.com/ice/3.8/slice/basic-types/ruby.md), [Swift](https://docs.zeroc.com/ice/3.8/slice/basic-types/swift.md).

## Built-In Basic Types

Slice provides a number of built-in basic types, as shown in this table:

| **Type** | **Range of Mapped Type** | **Size of Mapped Type** |
| --- | --- | --- |
| `bool` | `false` or `true` | ≥ 1 bit |
| `byte` | -128 to 127 or 0 to 255 | ≥ 8 bits |
| `short` | -2<sup>15</sup> to 2<sup>15</sup> - 1 | ≥ 16 bits |
| `int` | -2<sup>31</sup> to 2<sup>31</sup> - 1 | ≥ 32 bits |
| `long` | -2<sup>63</sup> to 2<sup>63</sup> - 1 | ≥ 64 bits |
| `float` | IEEE single-precision | ≥ 32 bits |
| `double` | IEEE double-precision | ≥ 64 bits |
| `string` | All Unicode characters | Variable-length |

The range of `byte` depends on whether the language mapping uses a signed or an unsigned type for it.

## Integer Types

Slice provides integer types `short`, `int`, and `long`, with 16-bit, 32-bit, and 64-bit ranges, respectively. Note that, on some architectures, any of these types may be mapped to a native type that is wider. Also note that no unsigned types are provided. (This choice was made because unsigned types are difficult to map into languages without native unsigned types, such as Java).

## Floating-Point Types

These types follow the IEEE specification for single- and double-precision floating-point representation [\[1\]](#references).

## Strings

Slice strings use the Unicode character set and are encoded using UTF-8 when transmitted between clients and servers.

## Booleans

Boolean values can have only the values `false` and `true`. Language mappings use the corresponding native boolean type if one is available.

## Bytes

The Slice type `byte` is an 8-bit type. A `sequence<byte>` carries binary data unchanged.

## Language Mapping

The Slice basic types map to JavaScript and TypeScript types as follows:

| **Slice** | **JavaScript** | **TypeScript** |
| --- | --- | --- |
| bool | `Boolean` | `boolean` |
| byte | `Number` | `number` |
| short | `Number` | `number` |
| int | `Number` | `number` |
| long | `BigInt` | `bigint` |
| float | `Number` | `number` |
| double | `Number` | `number` |
| string | `String` | `string` |

A proxy method also accepts an integer `number` for a `long` parameter. Pass a `bigint` for a value outside the range `Number.MIN_SAFE_INTEGER` to `Number.MAX_SAFE_INTEGER`, where a `number` loses precision.

## References

1. Institute of Electrical and Electronics Engineers. 2019. *IEEE 754-2019 Standard for Floating-Point Arithmetic*. Piscataway, NJ: Institute of Electrical and Electronics Engineers.
