85 {
88
89 auto sign = std::string(components.bits.sign ? "-" : "+");
90
92 {
93
94 if(components.bits.significand == 0) { return sign + "infinity"; }
95 else
96 {
97
98 char significandString[FloatComponents<Float>::numSignificandHexits + 1];
99 for(
Uptr hexitIndex = 0;hexitIndex < FloatComponents<Float>::numSignificandHexits;++hexitIndex)
100 {
101 auto hexitValue = char((components.bits.significand >> ((FloatComponents<Float>::numSignificandHexits - hexitIndex - 1) * 4)) & 0xf);
102 significandString[hexitIndex] = hexitValue >= 10 ? ('a' + hexitValue - 10) : ('0' + hexitValue);
103 }
104 significandString[FloatComponents<Float>::numSignificandHexits] = 0;
105 return sign + "nan:0x" + significandString + "";
106 }
107 }
108 else
109 {
110
111 char buffer[32];
112 auto numChars = std::sprintf(buffer,FloatComponents<Float>::numSignificandHexits == 6 ?
"%.6a" :
"%.13a",
f);
113 if(unsigned(numChars) + 1 > sizeof(buffer))
114 {
115 Errors::fatal(
"not enough space in Floats::asString buffer");
116 }
117 return buffer;
118 }
119 }
PointerIntHelper< sizeof(size_t)>::UnsignedIntType Uptr
void fatal(const char *message)