# Verse Clamp(float), Min, and Max are non-native

**URL:** <https://forums.unrealengine.com/t/verse-clamp-float-min-and-max-are-non-native/2877203>\
**Category:** Issues and Bug Reporting\
**Tags:** Status-Open, unreal-editor-for-fortnite, fortnite-creative, open, fortnite\
**Created:** [December 4, 2026, 5:05pm UTC](https://forums.unrealengine.com/t/verse-clamp-float-min-and-max-are-non-native/2877203 "2026-12-04T17:05:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![OohWowow](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/oohwowow/32/1003445_2.png) [@OohWowow](https://forums.unrealengine.com/u/OohWowow)\
**Post date:** [December 4, 2026, 5:05pm UTC](https://forums.unrealengine.com/t/verse-clamp-float-min-and-max-are-non-native/2877203/1 "2026-12-04T17:05:54Z")

</div>

### Summary

In /Verse.org/Verse (Verse.digest.verse:2128–2167), Clamp(int) and float math intrinsics (Sqrt, Sin, Cos, Tan) are @rtfm\_always\_open, while Clamp(float), Min(int/float), and Max(int/float) are non-native (= external {}). In server microbenchmarks, built-in Clamp(float) is ~8.8x slower than a one-line inline if/else clamp (~11.4 µs vs. ~1.3 µs per call).

In active multiplayer islands, float clamping runs heavily inside per-tick UI animations, progress bars, movement curves, and smoothers, needlessly eating into server tick headroom.

### Please select what you are reporting on:

Verse

### What Type of Bug are you experiencing?

Verse

### Steps to Reproduce

1. Add the minimal benchmark below to a Verse device in UEFN (43.x) and call BenchmarkFloatClamp() during an active session:

BenchmarkFloatClamp():void=  
Iterations := 50000  
var AccA: float = 0.0  
var AccB: float = 0.0

```
T0 := GetSecondsSinceEpoch()
for (I := 1..Iterations):
    X := (I * 0.00013) - 2.0
    set AccA += Clamp(X, 0.0, 1.0)
T1 := GetSecondsSinceEpoch()

for (I := 1..Iterations):
    X := (I * 0.00013) - 2.0
    set AccB += if (X < 0.0) then 0.0 else if (X > 1.0) then 1.0 else X
T2 := GetSecondsSinceEpoch()

Print("Built-in Clamp(float): {(T1 - T0) * 1000.0} ms | Inline if/else: {(T2 - T1) * 1000.0} ms | Check: {AccA}, {AccB}")

```

1. Launch a session and compare the printed timings for built-in Clamp(float) vs. inline if/else.

### Expected Result

Built-in Clamp(float), Min, and Max execute as intrinsics (matching Clamp(int) and Sqrt/Sin/Cos/Tan) at speeds equal to or faster than a hand-written inline if/else.

### Observed Result

- Built-in Clamp(Val:float, A:float, B:float) averages ~11.4 µs/call vs. ~1.3 µs/call for an inline if/else helper (~8.8x slower, 0.05% in-run repeatability).
- Min(Max(V, Lo), Hi) still carries +4.5 µs/call overhead because Min and Max are also non-native = external {}.
- In Verse.digest.verse:2128–2155:  
– Clamp(int) and Sqrt are declared @rtfm\_always\_open.  
– Clamp(float), Min(int/float), and Max(int/float) are declared = external {}

### Platform(s)

UEFN Server (all platforms)

---

<div class="post-metadata">

**Author:** ![Bug-Reporter](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bug-reporter/32/1223650_2.png) [@Bug-Reporter](https://forums.unrealengine.com/u/Bug-Reporter)\
**Post date:** [December 4, 2026, 6:59pm UTC](https://forums.unrealengine.com/t/verse-clamp-float-min-and-max-are-non-native/2877203/2 "2026-12-04T18:59:54Z")

</div>

FORT-1208458 has been created and its status is ‘Unconfirmed’. This is now in a queue to be reproduced and confirmed.

---

<div class="post-metadata">

**Author:** ![Sprintermax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sprintermax/32/1037175_2.png) [@Sprintermax](https://forums.unrealengine.com/u/Sprintermax)\
**Post date:** [December 4, 2026, 8:48pm UTC](https://forums.unrealengine.com/t/verse-clamp-float-min-and-max-are-non-native/2877203/3 "2026-12-04T20:48:18Z")

</div>

Wait, this does not make sense… you are not even supposed to be able to use `GetSecondsSinceEpoch()` like that, since calling it during the same tick/transaction should always give the same value frozen in time… (Only updates on suspends contexts across multiple ticks elapsed, same as GetSimulationElapsedTime())

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/b/4/1b45b6f89c11b0bc7585ab76da5a7a70577cd519.png)

If it is giving different values, then that is a bug and not intended behavior, not matching the specification and documentations.

Also just to annotate, this is the implementation of the built in Clamp/Min/Max functions (from Unreal Engine 6 source code):

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/1/f/a1f1d863e780c67cf423f92abacd8d7ff6d9f2ea.png)

Can you do the tests again, but now properly using `profile{}`? that is the expected macro to do benchmarks and profiling timings…

---

<div class="post-metadata">

**Author:** ![OohWowow](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/oohwowow/32/1003445_2.png) [@OohWowow](https://forums.unrealengine.com/u/OohWowow)\
**Post date:** [December 6, 2026, 2:44am UTC](https://forums.unrealengine.com/t/verse-clamp-float-min-and-max-are-non-native/2877203/4 "2026-12-06T02:44:41Z")

</div>

yeah great call out, the reproduction code is a little silly in retrospect and I appreciate the correction. I should not have rushed this report.

Re-tested using `profile(...),` the performance gap still reproduces:

| Block | Mean (ms) | Net / Call (minus empty loop) | Ratio |
| --- | --- | --- | --- |
| `EmptyFloatLoop` | `17.46` | — | — |
| `Inline if/else (float)` | `30.69` | `0.66 µs` | `1.0x` |
| `User ClampFloat (float)` | `45.16` | `1.39 µs` | `2.1x` |
| `Min(Max(float))` (`= external {}`) | `87.10` | `3.48 µs` | `5.3x` |
| `Clamp(float)` (`= external {}`) | `173.59` | `7.81 µs` | `11.8x` |
| `EmptyIntLoop` | `13.46` | — | — |
| `Clamp(int)` (`<native>`) | `21.67` | `0.41 µs` | `1.0x` |
| `Inline if/else (int)` | `32.26` | `0.94 µs` | `2.3x` |
| `Min(Max(int))` (`= external {}`) | `68.58` | `2.76 µs` | `6.7x` |

`<native>` `Clamp(int)` (`0.41 µs`) outperforms inline `if/else`, while non-`<native>` `Clamp(float)` (`7.81 µs`) is ~11.8x slower than inline and ~5.6x slower than a user-defined Verse helper.

**Updated `profile(...)` repro:**

```verse
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

ClampFloat<public>(V: float, Lo: float, Hi: float)<computes>:float =
    if (V < Lo) then Lo else if (V > Hi) then Hi else V

clamp_benchmark_device := class(creative_device):
    OnBegin<override>()<suspends>:void =
        Sleep(2.0)
        Iterations := 20000
        var Acc: float = 0.0
        var IntAcc: int = 0

        Sleep(0.1)
        profile("01_EmptyFloatLoop"):
            for (I := 1..Iterations):
                X := (I * 0.00013) - 2.0
                set Acc += X
        Sleep(0.1)
        profile("02_Builtin_Clamp_Float"):
            for (I := 1..Iterations):
                X := (I * 0.00013) - 2.0
                set Acc += Clamp(X, 0.0, 1.0)
        Sleep(0.1)
        profile("03_Builtin_MinMax_Float"):
            for (I := 1..Iterations):
                X := (I * 0.00013) - 2.0
                set Acc += Min(Max(X, 0.0), 1.0)
        Sleep(0.1)
        profile("04_UserFn_ClampFloat"):
            for (I := 1..Iterations):
                X := (I * 0.00013) - 2.0
                set Acc += ClampFloat(X, 0.0, 1.0)
        Sleep(0.1)
        profile("05_Inline_IfElse_Float"):
            for (I := 1..Iterations):
                X := (I * 0.00013) - 2.0
                set Acc += if (X < 0.0) then 0.0 else if (X > 1.0) then 1.0 else X
        Sleep(0.1)
        profile("06_EmptyIntLoop"):
            for (I := 1..Iterations):
                set IntAcc += I
        Sleep(0.1)
        profile("07_Builtin_Clamp_Int_Native"):
            for (I := 1..Iterations):
                set IntAcc += Clamp(I, 500, 15000)
        Sleep(0.1)
        profile("08_Builtin_MinMax_Int"):
            for (I := 1..Iterations):
                set IntAcc += Min(Max(I, 500), 15000)
        Print("Check: {Acc}, {IntAcc}")

```
