What is Kinda_Small_Number?

Okay so I’ve finally figured out how to use the API documentation :stuck_out_tongue: Embarrassingly when searching I didn’t notice the tabs above the search results where one could switch to “API” to quick jump to sections inside of it. Now I’ve been looking over all the stuff I wanted info on, one of which is the KINDA_SMALL_NUMBER that is all over the CharacterMovementComponent. I’ve been trying to understand how to interpret this. I figured this is something that has to do with limits and clamping values but what is this number exactly and how should I use it? It appears to work mostly with Vectors for identifying close to 1 or 0. what proximity is this best used with?

Thanks

if you want to determine if two floats are approximately equal, you need a standard way to say, “okay this is close enough”

`if(FMath::Abs(float1 - float2) < KINDA_SMALL_NUMBER)

KINDA_SMALL_NUMBER is equal to (1.e-4f) (0.00001)

and so this is the standardized way of saying “okay yes, the difference between these numbers is small enough to consider them equal”

It has other uses as well ofc but this is one important case

:slight_smile:

Rama

3 Likes

But how is it different from SMALL_NUMBER and when which should be used?

The reason this exists is because floats are not very precise.
For example, you can’t represent 0.1 with floats (using binary)

http://www.exploringbinary.com/why-0-point-1-does-not-exist-in-floating-point/

SMALL_NUMBER is smaller than KINDA_SMALL_NUMBER
but they are both very small, it depends on the kind of precision you are willing to accept when comparing 2 numbers with each other.
They are just 2 very very small numbers, one much smaller than the other.

Uses: If you want to compare the result of a division with a constant float, what you think should be 0.1 might not be 0.1, but 0.9999999999999999 and the other float ended up being 0.100000000000000001
so they are not equal, but they kind of are…

This function also uses SMALL_NUMBER as default parameter:

1 Like