canBeAHalf function
Check if a double can be represented as half precision. Returns true if it can be.
Implementation
bool canBeAHalf(double value) {
// Convert to half and back again.
final half = getHalfPrecisionInt(value);
final result = getHalfPrecisionDouble(half);
// If the value is the same it can be converted.
return result == value;
}