Is it a bug in printf() rounded ?

 
//+------------------------------------------------------------------+
//|                                          test_printf_rounded.mq5 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   double z=18.0;

   z=18.12345;
   printf("z=%.4f",z);//z=18.1234  why not rouned ?

   z=18.123451;
   printf("z=%.4f",z);//z=18.1235  rouned 

   z=18.12346;
   printf("z=%.4f",z);//z=18.1235  rouned

   z=18.123456;
   printf("z=%0.5f",z);//z=1.12346  rouned

  }
//+------------------------------------------------------------------+


 
 double z=18.12345;
   printf("z=%.19f",z);//z=18.1234  why not rouned ?
// z=18.1234499999999982833 was rounded down to zero.
No problem with printf, PICNIC. Floating point has infinite number of decimals, it's your not understanding floating point and that some numbers can't be represented exactly. (like 1/10.)
          Double-precision floating-point format - Wikipedia, the free encyclopedia

See also The == operand. - MQL4 and MetaTrader 4 - MQL4 programming forum

 
whroeder1:
Floating point has infinite number of decimals, it's your not understanding floating point and that some numbers can't be represented exactly. (like 1/10.)
          Double-precision floating-point format - Wikipedia, the free encyclopedia

See also The == operand. - MQL4 and MetaTrader 4 - MQL4 programming forum

Got it.

Thank you.

Reason: