Formatting decimal64

Is it possible to format decimal64 yang type in CLI output? I want to emit the output similar to what the format string “%12.2f” does with C printf().

Does flatformat work with decimal64? I can’t seem to get it to work with decimal64…

Thanks,
Raman

No, floatformat is not supposed to work with decimal64. But rjust:12 would work the same for you, provided your decimal64 is declared with fraction-digits 2.

I did set fraction-digits to 2 and am using rjust:12 right now.

However, when the fraction part (of value to be displayed) is a multiple of 10, the output contains only one 0 and the column alignment is not maintained. Here is an example where line 2 and 3 column 1 don’t align the decimal point.:

    2.49        14.15         0.04        18.37        23.73
    30.0        14.15         0.04        18.37        23.73
    22.5        14.14         0.04        18.37        23.73

Uh, that’s unfortunate. I’m not aware of any simple fix for that. There are still some options though:

  • employ so called user-defined types; it requires quite some coding though
  • you are supposed to be able to define your own template filter (all those floatformat, rjust etc. are all built-in template filters). But this is poorly documented, I’m not sure what needs to be done to make one work; from how it looks like it is a lot like a C-api cli command.

Defining my own template filter sounds very interesting. Would you please point me where to start?

Thanks,
Raman

I have never tried that myself and as I wrote, it appears to be very poorly documented (so poorly that it is somewhat questionable if it is wise to use it at all…). There are few references in man clispec and in man confd.conf, look for “templateFilter”.

You may also want to make use of your support account, I would expect your team has one.