MCPcopy Create free account
hub / github.com/csmith-project/csmith / GenerateSmallRandomFloatHexConstant

Function GenerateSmallRandomFloatHexConstant

src/Constant.cpp:194–214  ·  view source on GitHub ↗

* Generate small hexadecimal floating point constants */

Source from the content-addressed store, hash-verified

192 * Generate small hexadecimal floating point constants
193 */
194static string
195GenerateSmallRandomFloatHexConstant(int num)
196{
197 ostringstream oss;
198 if (num >= 0) {
199 oss << "0x";
200 }
201 else {
202 oss << "-0x";
203 num = -num;
204 }
205 oss << num << "." << RandomHexDigits(1) << "p";
206
207 if (pure_rnd_flipcoin(50)) {
208 oss << "+1";
209 }
210 else {
211 oss << "-1";
212 }
213 return oss.str();
214}
215
216static string
217GenerateRandomConstantInRange(const Type* type, int bound)

Callers 1

GenerateRandomConstantFunction · 0.85

Calls 2

RandomHexDigitsFunction · 0.85
pure_rnd_flipcoinFunction · 0.85

Tested by

no test coverage detected