# Getting a percentage of a Float or Integer

**URL:** <https://forums.unrealengine.com/t/getting-a-percentage-of-a-float-or-integer/394057>\
**Category:** Editor Scripting\
**Tags:** Variable, integer, unreal-engine, Blueprint, question\
**Created:** [May 19, 2017, 7:40pm UTC](https://forums.unrealengine.com/t/getting-a-percentage-of-a-float-or-integer/394057 "2017-05-19T19:40:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freudian](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Freudian](https://forums.unrealengine.com/u/Freudian)\
**Post date:** [May 19, 2017, 7:40pm UTC](https://forums.unrealengine.com/t/getting-a-percentage-of-a-float-or-integer/394057/1 "2017-05-19T19:40:45Z")

</div>

## Getting a percentage of a Float or Integer

I want to be able to set a Variable with a value that is equal to the percentage of another Integer or Float. For example, reducing the players movement speed at a percentage of 30%. The player, moving at a speed of 600 by default reduced by 30% (180) should give me 420 after calculating. I’m comfortable with the math I just cant for the life of me figure out how to calculate a percentage of an Integer. I basically just want to find a way of getting 30% of a Variable.

Thanks in advance  
-F

---

<div class="post-metadata">

**Author:** ![Jamie\_Dale](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jamie_dale/32/1165413_2.png) [@Jamie\_Dale](https://forums.unrealengine.com/u/Jamie_Dale)\
**Post date:** [May 19, 2017, 7:51pm UTC](https://forums.unrealengine.com/t/getting-a-percentage-of-a-float-or-integer/394057/2 "2017-05-19T19:51:37Z")

</div>

Multiply by a fraction.

- 1.0 = 100%
- 0.7 = 70%
- 0.3 = 30%

600 x 0.3 is 180, 600 x 0.7 is 420.

---

<div class="post-metadata">

**Author:** ![janimationd](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@janimationd](https://forums.unrealengine.com/u/janimationd)\
**Post date:** [May 19, 2017, 7:54pm UTC](https://forums.unrealengine.com/t/getting-a-percentage-of-a-float-or-integer/394057/3 "2017-05-19T19:54:19Z")

</div>

In unreal engine, movement speed is a float, so the speed you are referring to should start off as a float before you do your calculations…

After that the calculations are simple:

```
float normalSpeed = 600;
float percentModifier = -30;
float newSpeed = normalSpeed * (1 + (percentModifier / 100));
```

---

<div class="post-metadata">

**Author:** ![Freudian](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Freudian](https://forums.unrealengine.com/u/Freudian)\
**Post date:** [May 3, 2018, 7:46pm UTC](https://forums.unrealengine.com/t/getting-a-percentage-of-a-float-or-integer/394057/4 "2018-05-03T19:46:49Z")

</div>

Thanks and sorry for the long reply, I have been super busy it became pretty obvious when I sat down and had a second look at it that all’s I needed to do was treat 1 as 100% and just use decimal values ^\_^’

That’s where 3 AM scripting gets you I guess haha

Cheers, Freudian

---

<div class="post-metadata">

**Author:** ![mattyi85](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mattyi85](https://forums.unrealengine.com/u/mattyi85)\
**Post date:** [September 2, 2018, 2:58pm UTC](https://forums.unrealengine.com/t/getting-a-percentage-of-a-float-or-integer/394057/5 "2018-09-02T14:58:47Z")

</div>

I see this is an old thread but thought i would add another way to work out percentages for anyone else that might be looking like i was the other day.

If you don’t want rounded numbers (so you can have 0.5 for example) then using floats is best. if you want rounded numbers (1,2,3 etc) then i still convert integers to float then back to integers using ceiling or floor functions depending which way you want to round up.

The MATH - for example you want to work out 10% of 62 (answer is 6.2) i take my number 62 then divide that by 100 (= 0.62) then multiply that by 10 = 6.2 (10% of 62).

For other percentages you just change the end multiplication so 20 % would be 62 divided by 100 multiplied by 20 = 12.4  
multiply by 30 for 30% and so on.

 ![252452-screenshot-15.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/1/2/c127c424a8fc16c438b27fa11ba7da69e8ecd858.png)

---

<div class="post-metadata">

**Author:** ![Frednotbob](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Frednotbob](https://forums.unrealengine.com/u/Frednotbob)\
**Post date:** [February 21, 2019, 7:35pm UTC](https://forums.unrealengine.com/t/getting-a-percentage-of-a-float-or-integer/394057/6 "2019-02-21T19:35:11Z")

</div>

And another resurrection for those that look here in 2019:

As of 4.21.2, there is now an ‘as percent’ node available that will output the value of a float as ‘n%’. Logically, it’s under ‘text’, or you can right-click and search for ‘as percent’.

Keep in mind, though, that the integer will continue to increase past 100% unless you clamp the value of your float (not the min/max, but the value).

---

<div class="post-metadata">

**Author:** ![Jamie\_Dale](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jamie_dale/32/1165413_2.png) [@Jamie\_Dale](https://forums.unrealengine.com/u/Jamie_Dale)\
**Post date:** [February 21, 2019, 7:45pm UTC](https://forums.unrealengine.com/t/getting-a-percentage-of-a-float-or-integer/394057/7 "2019-02-21T19:45:54Z")

</div>

That node has existed since 4.0. It gives you a fractional number back as a culture correct percentage representation… but that wasn’t what the OP was asking for here, as they wanted a percentage of another number as a numeric value.

---

<div class="post-metadata">

**Author:** ![TorQueMoD](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/torquemod/32/710746_2.png) [@TorQueMoD](https://forums.unrealengine.com/u/TorQueMoD)\
**Post date:** [August 20, 2023, 2:42am UTC](https://forums.unrealengine.com/t/getting-a-percentage-of-a-float-or-integer/394057/8 "2023-08-20T02:42:24Z")

</div>

I realize this isn’t directly in the scope of what the OP was asking, but this is the top search result from Google, so I wanted to share how to compare a number as a percentage of another number and have this converted to a 0-1 range. This can be helpful if you’re trying to fill a progress bar for example.

Let’s imagine you have two numbers, a value representing the current progress (maybe your XP), and another representing the target (When you gain a level). You would divide the Current Progress by the Target to get its percentage of the target on a 0-1 scale.

![CompareNumbersAsPercentage](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/b/2/eb2d7c27a53fb4d43de9bffa354d8fc0b718112e.png)

This will work regardless of the values and is a great way to convert to a 0-1 range to fill a progress meter. If you want the percentage on a 0 - 100 scale, just multiply the result by 100.

---

<div class="post-metadata">

**Author:** ![Nizami\_Nz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nizami\_Nz](https://forums.unrealengine.com/u/Nizami_Nz)\
**Post date:** [May 23, 2025, 7:52pm UTC](https://forums.unrealengine.com/t/getting-a-percentage-of-a-float-or-integer/394057/9 "2025-05-23T19:52:31Z")

</div>

I wrote a function that finds a percentage of the total number.

> It can subtract a percentage from the total number (100hp - 20% = 80)

Or

> return the remainder of the number (20% of 100hp = 20)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/5/7/c57c6ea8c557b4d67a80db4355c1c887cab57122.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/a/6/ca6faec8702896b04095e686dad39a2510ae10fa.png)

> **[Find the percentage posted by Nizami | blueprintUE | PasteBin For Unreal Engine](https://blueprintue.com/blueprint/la9znhbv/)**
>
> No description provided
