VerseIsland
FeedLearnLeaderboardGuidesReferenceExploreSearchDocsVerse Library
Sign in
Feed Learn 📖 Codex Leaderboard Guides Reference Explore Search Docs Verse Library
Browse Community Snippets›Verse Language·Up to Community Snippets · Verse Language·62 of 114 in Verse Language

Math Utilities

Math Utilities

Numeric helpers Verse lacks out of the box: Modulo, ClampInt/Float, SafeDivide, RoundTo, LerpFloat, and a zero-safe vector SafeNormalize.

Original, compile-verified Verse by Bizanator (Biloxi Studios). Clean-room sample you can drop into a UEFN project and adapt.

  • # Math Utilities — Biloxi Studios Inc.
    #
    # Generic numeric helpers Verse doesn't ship out of the box: integer modulo,
    # clamping, safe division, rounding to N decimals, linear interpolation, and a
    # zero-safe vector normalize. Dependency-free.
    #
    # Teaches: <decides>/<transacts> effects, Int[]/Round[]/Floor[] failable casts,
    # guarding division by zero, and basic vector math.
    
    using { /Verse.org/Simulation }
    using { /UnrealEngine.com/Temporary/SpatialMath }
    
    math_utils<public> := module:
    
        # Integer modulo (remainder). Verse has no `%` operator, so we derive it from
        # integer division. Returns 0 when Divisor is 0 rather than failing.
        Modulo<public>(Dividend:int, Divisor:int)<transacts>:int =
            if (Divisor <> 0, Q := Quotient[Dividend, Divisor]):
                return Dividend - Q * Divisor
            0
    
        # Clamp an int into [Low, High].
        ClampInt<public>(Value:int, Low:int, High:int)<transacts>:int =
            Max(Low, Min(Value, High))

You're reading a preview

The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.

Sign in with Discord — free for members Read the original at Epic Games documentation

Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.

Guided course

Add this to your free study plan — we’ll suggest related material and stitch it into one compile-checked lesson.

Keep exploring
More in Verse Language · 62 of 114
Prev
event utils
Next
string utils

Source

Epic Games documentation

Bizanator

MIT

View original
VerseIsland· an archipelago of Verse & UEFN knowledge
🗺️ Island atlasLearnGuidesHistoryAbout & PressSources & LicensingPrivacy PolicyTermsStatus

Not affiliated with Epic Games. Fortnite, UEFN, Unreal Engine, and Verse are trademarks of Epic Games, Inc. Content is attributed to its source — see Sources & Licensing.

🦜

Scout · your island guide

The Isle of Verse