How to present a number in octal in MQL ?

To add comments, please log in or register
greentreen
86
greentreen  
   //--- octal  %o 
   int b=017; // octal:21    actual it is decimal
   printf("b=octal:%o,b=%d",b,b); //b=octal:21,b=17
Marco vd Heijden
Moderator
8156
Marco vd Heijden  
Documentation on MQL5: Common Functions / PrintFormat
Documentation on MQL5: Common Functions / PrintFormat
  • www.mql5.com
The number, order and type of parameters must exactly match the set of qualifiers, otherwise the print result is undefined. Instead of PrintFormat() you can use If the format string is followed by parameters, this string must contain format specifications that denote output format of these parameters. Specification of format always starts with...
greentreen
86
greentreen  
Marco vd Heijden:
Hello please see: https://www.mql5.com/en/docs/common/printformat

Thanks. 

What I need is the presentation of number in octal  instead of output value in octal.

int x = 10;// in decimal

int y = 0x10;// in hex

int z = 010;// it is octal in C++ and it is equal 8 ,but it is not octal in MQL,it is still decimal in MQL

printf("%o",z)  --- //this is output by octal.

whroeder1
17943
whroeder1  
greentreen: What I need is the presentation of number in octal  instead of output value in octal.
  1. The only mention of octal in the documentation is PrintFormat. So no 010.
  2. Does anyone use it any more? You know what octal is, convert it to hex and use that.
              Language Basics / Data Types / Integer Types / Char, Short, Int and Long Types - Reference on algorithmic/automated trading language for MetaTrader 5
Alain Verleyen
36039
Alain Verleyen  
I hope you will not created a topic on each difference between C++ and MQL languages.
Marco vd Heijden
Moderator
8156
Marco vd Heijden  
Alain Verleyen:
I hope you will not created a topic on each difference between C++ and MQL languages.

I just wished they were the same.

Alain Verleyen
36039
Alain Verleyen  
Marco vd Heijden:

I just wished they were the same.

They are far from the same.
Marco vd Heijden
Moderator
8156
Marco vd Heijden  
Alain Verleyen:
They are far from the same.

Yes but they seem to be getting closer.

Maybe i wished it was more like Python.

I mean a more modern language as it is hard to work with larger numbers on the older ones.

I want to do it in C++ , because it's fast.

vs.

I want to do it in Python, because it's easy.

Usually i end up doing it in C++ as well as in Python and i will even port it partially to Javascript.

But Python always wins even though its a magnitude of 40x slower than C since it's an interpreter language.

whroeder1
17943
whroeder1  
Alain Verleyen: I hope you will not created a topic on each difference between C++ and MQL languages.
Already exists.
          how similar is C++ verses MQL5? - MetaTrader 4 - General - MQL5 programming forum
greentreen
86
greentreen  

Thank you.

To add comments, please log in or register