Implement RtlInfiniteDouble() and RtlNanDouble() routines
All checks were successful
Builds / ExectOS (amd64) (push) Successful in 59s
Builds / ExectOS (i686) (push) Successful in 21s

This commit is contained in:
Rafal Kupiec 2024-02-21 19:55:16 +01:00
parent 562b89e4d4
commit 0c7cf6f6d3
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
2 changed files with 76 additions and 0 deletions

View File

@ -260,6 +260,10 @@ LONG
RtlGetBaseExponent(IN DOUBLE Value,
OUT PDOUBLE PowerOfTen);
XTCDECL
BOOLEAN
RtlInfiniteDouble(IN DOUBLE Value);
XTCDECL
VOID
RtlInitializeListHead(IN PLIST_ENTRY ListHead);
@ -286,6 +290,10 @@ XTCDECL
BOOLEAN
RtlListLoop(IN PLIST_ENTRY ListHead);
XTCDECL
BOOLEAN
RtlNanDouble(IN DOUBLE Value);
XTCDECL
VOID
RtlRemoveEntryList(IN PLIST_ENTRY Entry);

View File

@ -600,6 +600,40 @@ RtlGetBaseExponent(IN DOUBLE Value,
return Exponent;
}
/**
* Determines whether a floating-point number is infinite.
*
* @param Value
* Supplies the floating-point value to test.
*
* @return This routine returns TRUE if the argument is infinite or a NaN, or FALSE otherwise.
*
* @since XT 1.0
*/
XTCDECL
BOOLEAN
RtlInfiniteDouble(IN DOUBLE Value)
{
/* DOUBLE argument in IEEE 754 standard format */
union
{
PDOUBLE Double;
struct
{
UINT MantissaLow:32;
UINT MantissaHigh:20;
UINT Exponent:11;
UINT Sign:1;
} *DoubleS;
} Var;
/* Convert input double value to IEEE 754 format */
Var.Double = &Value;
/* Return TRUE if it is infinite, or FALSE otherwise */
return ((Var.DoubleS->Exponent & 0x7FF) == 0x7FF);
}
/**
* Multiplies a signed large integer by a signed integer.
*
@ -624,3 +658,37 @@ RtlMultiplyLargeInteger(IN LARGE_INTEGER Multiplicand,
LargeInt.QuadPart = (LONGLONG) Multiplicand.QuadPart * Multiplier;
return LargeInt;
}
/**
* Determines whether a floating-point number is a NaN ("Not a Number").
*
* @param Value
* Supplies the floating-point value to test.
*
* @return This routine returns TRUE if the argument is a NaN, or FALSE otherwise.
*
* @since XT 1.0
*/
XTCDECL
BOOLEAN
RtlNanDouble(IN DOUBLE Value)
{
/* DOUBLE argument in IEEE 754 standard format */
union
{
PDOUBLE Double;
struct
{
UINT MantissaLow:32;
UINT MantissaHigh:20;
UINT Exponent:11;
UINT Sign:1;
} *DoubleS;
} Var;
/* Convert input double value to IEEE 754 format */
Var.Double = &Value;
/* Return TRUE if it is NaN, or FALSE otherwise */
return (Var.DoubleS->Exponent == 0x7FF && (Var.DoubleS->MantissaHigh != 0 || Var.DoubleS->MantissaLow != 0));
}