# Wrap (Integer) Not Picking Min Value

**URL:** <https://forums.unrealengine.com/t/wrap-integer-not-picking-min-value/741415>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [January 3, 2023, 7:50pm UTC](https://forums.unrealengine.com/t/wrap-integer-not-picking-min-value/741415 "2023-01-03T19:50:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonyfries](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jonyfries](https://forums.unrealengine.com/u/jonyfries)\
**Post date:** [January 3, 2023, 7:50pm UTC](https://forums.unrealengine.com/t/wrap-integer-not-picking-min-value/741415/1 "2023-01-03T19:50:23Z")

</div>

I found the Wrap (Integer) node today and was excited to use that for wrapping around arrays but it seems to never wrap to the bottom value.

So with a Min of 0, a Max of 2, and an Value of 3 the Integer (Wrap) will select 1 rather than 0 which is what I would expect. It can’t be worked around by simply reducing the min value by 1 as it will return 0 if 0 is given in the above example.

Below are screen shots of the blueprint that I used to test the value 0, I replicated the same blueprint but updated the values as indicated in the screen shot within the game.

Am I missing something obvious in how this is supposed to be used or is this a bug?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/9/6/696456d2c1b3c1c015bf3c1f50ecfd4a00c66eb6.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/0/d/60d294026210f04156d0e7e4a9be2d9d1bfeabfd.png)

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [January 3, 2023, 9:03pm UTC](https://forums.unrealengine.com/t/wrap-integer-not-picking-min-value/741415/2 "2023-01-03T21:03:06Z")

</div>

This seems to be an awkwardly named method.  
The wrap node is from the KismetMath library and is commented

```auto
/** Returns Value between A and B (inclusive) that wraps around */

```

The library is just a wrapper to another library (FMath) which comments the same method as

```auto
/** Wraps X to be between Min and Max, inclusive */

```

This wrap node does not at all as you would expect wrap “around” to the Min or Max number, instead it returns a number within the min and max.

If you want to wrap around an array you should write your own macro to do so. A macro because macros work with arrays of any datatype, similar to a templated method.

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [January 3, 2023, 9:04pm UTC](https://forums.unrealengine.com/t/wrap-integer-not-picking-min-value/741415/3 "2023-01-03T21:04:34Z")

</div>

Here is an example

 ![afbeelding](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/c/6/1c6dc8579e4b633051fd97f3a3e3745847a48096.png)

---

<div class="post-metadata">

**Author:** ![jonyfries](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jonyfries](https://forums.unrealengine.com/u/jonyfries)\
**Post date:** [January 3, 2023, 11:08pm UTC](https://forums.unrealengine.com/t/wrap-integer-not-picking-min-value/741415/4 "2023-01-03T23:08:13Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/c/e/dce0ff93702098a9271a007ae46edf3f1eae007f.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/0/7/40701f10a7739e400cf6ac07135fd192801614da.png)

I see you’re doing more than just wrapping the integer value but, to recreate the functionality I expected I put together the above snippet.

---

<div class="post-metadata">

**Author:** ![jonyfries](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jonyfries](https://forums.unrealengine.com/u/jonyfries)\
**Post date:** [January 4, 2023, 1:25am UTC](https://forums.unrealengine.com/t/wrap-integer-not-picking-min-value/741415/5 "2023-01-04T01:25:53Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/8/2/e8224b8b3e50e5502f0240e313d52ce73e6614f6.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/a/5/ea5773e209bfe69c458c0081f53952ce6977cb38.png)

For the more specific question of wrapping around an array this snippet is a bit more compact.
