Home Explore Blog CI



nushell

2nd chunk of `book/types_of_data.md`
9970b55f3c66fa3844b08b28d98e0187b4e6f17b152393bd0000000100000fb1
|                       |                                                                                                                                                           |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **_Description:_**    | Numbers without a fractional component (positive, negative, and 0)                                                                                        |
| **_Annotation:_**     | `int`                                                                                                                                                     |
| **_Literal Syntax:_** | A decimal, hex, octal, or binary numeric value without a decimal place. E.g., `-100`, `0`, `50`, `+50`, `0xff` (hex), `0o234` (octal), `0b10101` (binary) |
| **_See also:_**       | [Language Reference - Integer](/lang-guide/chapters/types/basic_types/int.md)                                                                             |

Simple Example:

```nu
10 / 2
# => 5
5 | describe
# => int
```

### Floats/Decimals

|                       |                                                                                  |
| --------------------- | -------------------------------------------------------------------------------- |
| **_Description:_**    | Numbers with some fractional component                                           |
| **_Annotation:_**     | `float`                                                                          |
| **_Literal Syntax:_** | A decimal numeric value including a decimal place. E.g., `1.5`, `2.0`, `-15.333` |
| **_See also:_**       | [Language Reference - Float](/lang-guide/chapters/types/basic_types/float.md)    |

Simple Example:

```nu
2.5 / 5.0
# => 0.5
```

::: tip
As in most programming languages, decimal values in Nushell are approximate.

```nu
10.2 * 5.1
# => 52.01999999999999
```

:::

### Text/Strings

|                       |                                                                                 |
| --------------------- | ------------------------------------------------------------------------------- |
| **_Description:_**    | A series of characters that represents text                                     |
| **_Annotation:_**     | `string`                                                                        |
| **_Literal Syntax:_** | See [Working with strings](working_with_strings.md)                             |
| **_See also:_**       | [Handling Strings](/book/loading_data.html#handling-strings)                    |
|                       | [Language Reference - String](/lang-guide/chapters/types/basic_types/string.md) |

As with many languages, Nushell provides multiple ways to specify String values and numerous commands for working with strings.

Simple (obligatory) example:

```nu
let audience: string = "World"
$"Hello, ($audience)"
# => Hello, World
```

### Booleans

|                       |                                                                                |
| --------------------- | ------------------------------------------------------------------------------ |
| **_Description:_**    | True or False value                                                            |
| **_Annotation:_**     | `bool`                                                                         |
| **_Literal Syntax:_** | Either a literal `true` or `false`                                             |
| **_See also:_**       | [Language Reference - Boolean](/lang-guide/chapters/types/basic_types/bool.md) |

Booleans are commonly the result of a comparison. For example:

```nu
let mybool: bool = (2 > 1)
$mybool
# => true
let mybool: bool = ($env.HOME | path exists)
$mybool
# => true
```

A boolean result is commonly used to control the flow of execution:

```nu
let num = -2
if $num < 0 { print "It's negative" }
# => It's negative

Title: Basic Data Types Continued: Integers, Floats, Strings, and Booleans
Summary
This section details integers (int), floats/decimals (float), strings (string), and booleans (bool) in Nushell. It provides descriptions, annotations, literal syntax, and examples for each type. Integers are whole numbers, floats are numbers with fractional components, strings are text series, and booleans are true/false values. The section includes links to language reference pages for each data type.