MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / sigFig

Function sigFig

util/glreadtest.cpp:81–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79
80
81char *sigFig(int fig, char *string, double value)
82{
83 char format[80];
84 double _l = (value == 0.0) ? 0.0 : log10(fabs(value)); int l;
85 if(_l < 0.)
86 {
87 l = (int)fabs(floor(_l));
88 snprintf(format, 79, "%%%d.%df", fig + l + 1, fig + l - 1);
89 }
90 else
91 {
92 l = (int)_l + 1;
93 if(fig <= l) snprintf(format, 79, "%%.0f");
94 else snprintf(format, 79, "%%%d.%df", fig + 1, fig - l);
95 }
96 snprintf(string, STRLEN - 1, format, value);
97 return string;
98}
99
100
101extern "C" {

Callers 2

writeTestFunction · 0.85
readTestFunction · 0.85

Calls 1

floorFunction · 0.85

Tested by

no test coverage detected