# Force a float into an integer value

**URL:** https://discussions.unity.com/t/force-a-float-into-an-integer-value/747411
**Category:** Scripting
**Tags:** Scripting
**Created:** [June 17, 2019, 1:46am UTC](https://discussions.unity.com/t/force-a-float-into-an-integer-value/747411 "2019-06-17T01:46:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![TortoRacoon](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/tortoracoon/32/549223_2.png) [@TortoRacoon](https://discussions.unity.com/u/TortoRacoon)
#### Post date: [June 17, 2019, 1:46am UTC](https://discussions.unity.com/t/force-a-float-into-an-integer-value/747411/1 "2019-06-17T01:46:44Z")

</div>

Very easy and quick question.

I want characters to increment a 10% of their current health when leveling up. Sometimes that number is not an integer (I need them to be integer for something very important). Can I make it take the 10% of the number and force that number to take an equivalent as an int number?

Thanks in advance

---

<div class="post-metadata">

### Author: ![Brathnann](https://avatars.discourse-cdn.com/v4/letter/b/e5b9ba/32.png) [@Brathnann](https://discussions.unity.com/u/Brathnann)
#### Post date: [June 17, 2019, 4:14am UTC](https://discussions.unity.com/t/force-a-float-into-an-integer-value/747411/2 "2019-06-17T04:14:11Z")

</div>

```csharp
float aFloat = 5.125f;
int aInt = (int)aFloat;

```

---

<div class="post-metadata">

### Author: ![jvo3dc](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jvo3dc](https://discussions.unity.com/u/jvo3dc)
#### Post date: [June 17, 2019, 11:23am UTC](https://discussions.unity.com/t/force-a-float-into-an-integer-value/747411/3 "2019-06-17T11:23:00Z")

</div>

```auto
float aFloat = 5.615f;
int aInt = Mathf.FloorToInt(aFloat); // 5
aInt = Mathf.RoundToInt(aFloat); // 6
aInt = Mathf.CeilToInt(aFloat); // 6

```
