How to change floating point model

Running my game today in the “Development Editor” configuration I encountered bugs that weren’t present in the “DebugGame Editor” configuration, which I tracked down to floating point issues caused by the /fp:fast floating point model compiler flag in the former configuration in contrast to the /fp:precise flag in the latter.

Now I want to change the floating point model (preferably only for my game module) in the Shipping and Development configurations, but I don’t know where to do this.

Any help is appreciated.

I don’t think there is way, i don’t see way to edit arguments directly and configuration configs are not tied in the way to effectivily control perticilar once you looking for. Look up here:

https://github.com/EpicGames/UnrealEngine/blob/dbced2dd59f9f5dfef1d7786fd67ad2970adf95f/Engine/Source/Programs/UnrealBuildTool/Platform/Windows/VCToolChain.cs

So most likely you will need to edit UBT code

Thank you for your answer! Yesterday I looked into the config options as well and I suspect that you are right and that I need to change the UBT code. For testing purposes I completely removed the

if (!WindowsPlatform.bCompileWithICL)
{
    // Relaxes floating point precision semantics to allow more optimization.
    Arguments.Add("/fp:fast");
}

part and after recompiling the engine it seems as if the bug has gone. However, the result is still slightly different from when run on a standard vc project configuration, so there might be another difference in the compiler arguments or a bug in my code.

You do not need to alter the unreal engine code for this. You can use pragmas to specify exactly what parts of the fp:precise / strict / except / fast specifications you want, for more information see float_control pragma | Microsoft Docs

I suggest you make a header with your specification and you include that one in every file where you need this. You can only enforce this by an informal policy in your project, but at least it allows you to have full control. Similar flags are available

My header looks like this, basically emulating fp:strict:

#pragma once

// This is practically equivalent to /fp:strict, see https://docs.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior?view=vs-2019
#pragma float_control(precise, on)
#pragma float_control(except, on)
#pragma fenv_access(on)
#pragma fp_contract(off)
#define _CRT_SECURE_NO_WARNINGS

As you see I also turned off fma optimizations and secure warnings.

Some more information can be found here:

For Clang and other compilers you may want to use with Unreal Engine, you should be able to find similar pragmas.