> For the complete documentation index, see [llms.txt](https://hopemoore.gitbook.io/coding-for-creatives-spring-2021/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hopemoore.gitbook.io/coding-for-creatives-spring-2021/glossary-and-terms/variables/data-types/floating-point-or-float.md).

# Floating Point or Float

## Description

* Number with a decimal point
* Used for precision
* Used for percentages, but between 0 and 1 (0 and 100%)
* Used for time

**Examples:**

*Processing:*

```java
float speed = 2.5;
```

*JavaScript:*

```javascript
var percentage = 0.25;
```

*Python:*

```python
percentage = 0.25
```

{% hint style="info" %}
Some languages have multiple types with decimal points

Example: a float in C# or Unity will need an `F` after the number in the code to tell it is a float and not something els&#x65;**.** See the example below.
{% endhint %}

```csharp
float speed = 2.5F;
```

^ This is one of the more common errors - forgetting that F.

{% hint style="warning" %}
Do not use commas in your numbers!
{% endhint %}

## Shortcuts (Assignment Operators)

### Quick Math

**`+=`** means “add this”

**`-=`** means “subtract this”

**`*=`** means “multiply it by this”

**`/=`** means “divide it by this”

{% hint style="warning" %}
This updates the variable when used.
{% endhint %}

**Example:**   &#x20;

*Processing, Java-based, and C-based:*

```java
float opacity = 0.5;

println(opacity);        // Prints "0.5"

opacity += 0.15;

println(opacity);        // Prints "0.65"
```

*Python:*

```python
opacity = 0.5

print(opacity)        # Prints "0.5"

opacity += 0.15

print(opacity)        # Prints "0.65"
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hopemoore.gitbook.io/coding-for-creatives-spring-2021/glossary-and-terms/variables/data-types/floating-point-or-float.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
