Changeset 833


Ignore:
Timestamp:
11/27/18 01:10:41 (5 years ago)
Author:
Maciej Komosinski
Message:

Introduced #define PRINTFLOAT_DRAGON4_ALWAYS_3_DIGIT_EXPONENT - when defined, it will always print 3 digits in exponent (zero-padding if necessary)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/PrintFloat/PrintFloat.cpp

    r823 r833  
    1 // One modification by macko in FormatScientific(): use 3 digits of exponent only if necessary (e+123), otherwise use two if necessary (e+45), otherwise use one (e+6)
     1// One modification by macko in FormatScientific(): use 3 digits of exponent only if necessary (e+123), otherwise use two if necessary (e+45), otherwise use one (e+6).
    22// This is consistent with java and javascript, and partially with python (which never uses one digit, only two or three).
     3// To always print 3 digits in exponent (zero-padding if necessary), uncomment:
     4// #define PRINTFLOAT_DRAGON4_ALWAYS_3_DIGIT_EXPONENT
    35
    46
     
    334336                // modified by macko: use 3 digits of exponent only if necessary (e+123), otherwise use two if necessary (e+45), otherwise use one (e+6)
    335337                unsigned int bufferIndex = 2;
     338#ifndef PRINTFLOAT_DRAGON4_ALWAYS_3_DIGIT_EXPONENT
    336339                if (hundredsPlace != 0) //3 digits needed
     340#endif
    337341                        exponentBuffer[bufferIndex++] = (tC8)('0' + hundredsPlace);
     342#ifndef PRINTFLOAT_DRAGON4_ALWAYS_3_DIGIT_EXPONENT
    338343                if (hundredsPlace != 0 || tensPlace != 0) //2 digits needed
     344#endif
    339345                        exponentBuffer[bufferIndex++] = (tC8)('0' + tensPlace);
    340346                exponentBuffer[bufferIndex++] = (tC8)('0' + onesPlace);
Note: See TracChangeset for help on using the changeset viewer.