Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-bugs: [Wireshark-bugs] [Bug 6527] corba dissector generator improvement

Date: Wed, 2 Nov 2011 13:46:18 -0700 (PDT)
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6527

--- Comment #9 from c.David <pub.david@xxxxxxx> 2011-11-02 13:46:16 PDT ---
Actually, The readability problems I had were with float data display with
figures over 1e+6, this is why originally I selected %f display. for the
doubles I completely agree with you, %g is well suited for whatever figures.
About float, for small figures, I do not what I had in mind with my previous
proposition :8-/ ...

Therefore I propose you this solution and results:

#include <stdio.h>
#include <math.h>

static const float  FLT_DISPLAY_HIGH = 1e9;
static const float  FLT_DISPLAY_LOW = 1e-4;

int
main(void)
{
    float f;
    double d;
    int i;

    f = 1.5e-8;
    d = 1.5e-8;
    for (i = -8; i < 15; i++) {
        printf("float: ");
       if((fabsf(f)>FLT_DISPLAY_HIGH)||(fabsf(f)<FLT_DISPLAY_LOW))
            printf("%.6g, ", f);
        else
            printf("%.6f, ", f);
        printf("%.6g, ", f);

        printf("%.15g\n", d);

        f *= 10;
        d *= 10;
    }
    return 0;
}
$ gcc a.c 
$ ./a.out 
float: 1.5e-08, 1.5e-08, 1.5e-08
float: 1.5e-07, 1.5e-07, 1.5e-07
float: 1.5e-06, 1.5e-06, 1.5e-06
float: 1.5e-05, 1.5e-05, 1.5e-05
float: 0.000150, 0.00015, 0.00015
float: 0.001500, 0.0015, 0.0015
float: 0.015000, 0.015, 0.015
float: 0.150000, 0.15, 0.15
float: 1.500000, 1.5, 1.5
float: 14.999999, 15, 15
float: 149.999985, 150, 150
float: 1499.999878, 1500, 1500
float: 14999.999023, 15000, 15000
float: 149999.984375, 150000, 150000
float: 1499999.875000, 1.5e+06, 1500000
float: 14999999.000000, 1.5e+07, 15000000
float: 149999984.000000, 1.5e+08, 150000000
float: 1.5e+09, 1.5e+09, 1500000000
float: 1.5e+10, 1.5e+10, 15000000000
float: 1.5e+11, 1.5e+11, 150000000000
float: 1.5e+12, 1.5e+12, 1500000000000
float: 1.5e+13, 1.5e+13, 15000000000000
float: 1.5e+14, 1.5e+14, 150000000000000

this would leave the generated dissector with an easy customization capability

Can you give me your opinion before I propose it as a patch.

-- 
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.