C#: Change NaN with large number (#817)
Summary:
This PR is the C# version of 3a82d2b1a8
The above change moved Yoga away from NaN to facilitate usage of the `-ffast-math` compiler flag. However, that commit forgot to update the C# implementation.
Pull Request resolved: https://github.com/facebook/yoga/pull/817
Differential Revision: D10282642
Pulled By: shergin
fbshipit-source-id: 51681ce12344bc421f346ccc30e2950f4f39dbc6
This commit is contained in:
committed by
Facebook Github Bot
parent
36e732aabd
commit
bb3c2b2498
@@ -9,11 +9,28 @@ namespace Facebook.Yoga
|
||||
{
|
||||
public static class YogaConstants
|
||||
{
|
||||
public const float Undefined = float.NaN;
|
||||
/**
|
||||
* Large positive number signifies that the property(float) is undefined. Earlier we used to have
|
||||
* YGundefined as NAN, but the downside of this is that we can't use -ffast-math compiler flag as
|
||||
* it assumes all floating-point calculation involve and result into finite numbers. For more
|
||||
* information regarding -ffast-math compiler flag in clang, have a look at
|
||||
* https://clang.llvm.org/docs/UsersManual.html#cmdoption-ffast-math
|
||||
*/
|
||||
public const float Undefined = 10E20F;
|
||||
|
||||
public static bool IsUndefined(float value)
|
||||
{
|
||||
return float.IsNaN(value);
|
||||
// Value of a float in the case of it being not defined is 10.1E20. Earlier it used to be NAN,
|
||||
// the benefit of which
|
||||
// was that if NAN is involved in any mathematical expression the result was NAN. But since we
|
||||
// want to have `-ffast-math`
|
||||
// flag being used by compiler which assumes that the floating point values are not NAN and Inf,
|
||||
// we represent YGUndefined as 10.1E20.
|
||||
// But now if YGUndefined is involved in any mathematical operations this value(10.1E20) would
|
||||
// change.
|
||||
// So the following check makes sure that if the value is outside a range (-10E8, 10E8) then it
|
||||
// is undefined.
|
||||
return value >= 10E8F || value <= -10E8;
|
||||
}
|
||||
|
||||
public static bool IsUndefined(YogaValue value)
|
||||
|
Reference in New Issue
Block a user