Precision on printing variables in interactive session: feature or bug?

Dear all,
what I want to report is a rather annoying feature (if not a bug):

$ root 
   ------------------------------------------------------------
  | Welcome to ROOT 6.11/01                http://root.cern.ch |
  |                               (c) 1995-2017, The ROOT Team |
  | Built for macosx64                                         |
  | From tag v6-09-02-2657-g9339de9e64, 18 May 2017            |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------


Applying ATLAS style settings...

root [0] double Cdep = 1.65428e-12
(double) 0.000000
root [1] Cdep
(double) 0.000000
root [2] Cdep/1e-12
(double) 1.654280

Is it normal that my variable is presented as consistent with 0?
Luckily the correct value it is still there.

Am I missing something?
Best regards,
Marco Bomben

$ root
   ----------------------------------------------------------------
  | Welcome to ROOT 6.11/03                    http://root.cern.ch |
  |                                   (c) 1995-2017, The ROOT Team |
  | Built for macosx64                                             |
  | From heads/master@v6-11-02-590-g814f647, Nov 03 2017, 15:38:50 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'     |
   ----------------------------------------------------------------

root [0] double Cdep = 1.65428e-12;
root [1] printf("%g\n",Cdep);
1.65428e-12
root [2] 

Thanks. Still rather annoying in my opinion.
Regards,
Marco Bomben

ROOT command line is interpreted C++ . You should type C++.

1 Like

I see, but few months ago it was different:

$ root 
   ------------------------------------------------------------
  | Welcome to ROOT 6.08/06                http://root.cern.ch |
  |                               (c) 1995-2016, The ROOT Team |
  | Built for linuxx8664gcc                                    |
  | From tag v6-08-06, 2 March 2017                            |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------

root [0] double Cdep = 1.6e-12
(double) 1.60000e-12
root [1] Cdep
(double) 1.60000e-12
root [2]

Ok. I am sure @Axel tell more about it.

I guess it’s due to this change:


to:

To be honest, it would be great to have something like std::setprecision for the output stream within cling, but the implementation seems to work with normal strings and not streams which seems a bit unfortunate :frowning:

I agree that’s bad; I’ll fix it at least for 6.12: https://github.com/root-project/root/pull/1278

If you want setprecision just use it :wink: You can always use printf or the iostream manipulators from the prompt. But we should still get the default right and sensible.

2 Likes

Thanks a lot you all for the feedback!
Best regards,
Marco Bomben

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.