# Difference between revisions of "Floating Point Number"

esse quam videri

(Created page with "=Definition= =Relevance= =Explanation= =Resources= == See also == * Float * C Sharp Data Types * SQL Data Types * .NET Data Types ==Notes== ==External...") |
|||

(2 intermediate revisions by the same user not shown) | |||

Line 1: | Line 1: | ||

=Definition= | =Definition= | ||

+ | A float (short for floating-point number) is a data type that has 32 bits of space. | ||

=Relevance= | =Relevance= | ||

+ | Floats are commonly used for complex numbers in programming. Being floating-point numbers, floats can hold decimal precision. | ||

=Explanation= | =Explanation= | ||

+ | Floats can be used for arithmetic expressions such as addition, multiplication, division in programming. | ||

+ | <syntaxhighlight lang ="csharp"> | ||

+ | float a = 5f; // notice the f after the number, this is necessary to specify that the value is a float. | ||

+ | float b = 2.5f; | ||

+ | float result1, result2, result3; // You can also declare several variables of the same type this way. | ||

+ | |||

+ | result1 = a + b; // result1 = 7.5f | ||

+ | result2 = a * b; // result2 = 12.5f | ||

+ | result3 = a / b; // result3 = 2f | ||

+ | </syntaxhighlight> | ||

− | |||

== See also == | == See also == | ||

* [[Float]] | * [[Float]] | ||

Line 14: | Line 25: | ||

* [[.NET Data Types]] | * [[.NET Data Types]] | ||

− | |||

− | |||

## Latest revision as of 16:00, 8 August 2019

## Contents

# Definition

A float (short for floating-point number) is a data type that has 32 bits of space.

# Relevance

Floats are commonly used for complex numbers in programming. Being floating-point numbers, floats can hold decimal precision.

# Explanation

Floats can be used for arithmetic expressions such as addition, multiplication, division in programming.

```
float a = 5f; // notice the f after the number, this is necessary to specify that the value is a float.
float b = 2.5f;
float result1, result2, result3; // You can also declare several variables of the same type this way.
result1 = a + b; // result1 = 7.5f
result2 = a * b; // result2 = 12.5f
result3 = a / b; // result3 = 2f
```