MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / NiceNum

Function NiceNum

Source/3rdParty/implot/implot.cpp:441–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

439}
440
441double NiceNum(double x, bool round) {
442 double f;
443 double nf;
444 int expv = (int)floor(ImLog10(x));
445 f = x / ImPow(10.0, (double)expv);
446 if (round)
447 if (f < 1.5)
448 nf = 1;
449 else if (f < 3)
450 nf = 2;
451 else if (f < 7)
452 nf = 5;
453 else
454 nf = 10;
455 else if (f <= 1)
456 nf = 1;
457 else if (f <= 2)
458 nf = 2;
459 else if (f <= 5)
460 nf = 5;
461 else
462 nf = 10;
463 return nf * ImPow(10.0, expv);
464}
465
466//-----------------------------------------------------------------------------
467// Context Utils

Callers 2

Locator_DefaultFunction · 0.85
Locator_TimeFunction · 0.85

Calls 3

ImLog10Function · 0.85
ImPowFunction · 0.85
floorFunction · 0.50

Tested by

no test coverage detected