RealDocs

UKismetMathLibrary::SignOfFloat

function Engine Blueprint Since 4.0
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticBlueprintPureUFUNCTION

Description

Returns -1.0 if A is negative, 0.0 if A is exactly zero, and +1.0 if A is positive.

Caveats & Gotchas

  • Returns exactly 0.0 for A == 0.0, unlike FMath::Sign which returns +1 for zero in some engine versions. Verify the expected zero behavior when porting between these two.
  • Returns a double (not int), so comparing the result with == to integer literals in C++ requires care. Blueprint pins it as float, which may cause a silent precision narrowing.

Signature

static UE_INL_API double SignOfFloat(double A);

Parameters

Name Type Description Default
A double The value whose sign to evaluate.

Return Type

double

Example

Apply a force in the direction of a velocity component C++
double VelocityX = -42.5;
double Direction = UKismetMathLibrary::SignOfFloat(VelocityX); // returns -1.0
FVector Force = FVector(Direction * ForceMagnitude, 0.0, 0.0);

Tags

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.