API return values different in simple queue

Dears,

I use api to get info about users, but in one board with mikrotik 6.18 the max-limit on queue simple is returning values with letter M or Kb.

Sample:
4M is returning 4000000 instead 4M
6M is returning 6000000 instead 6M

How change this ?

Sorry for my bad english.

Thanks to advance.

Simply do the calculation within your programming language.

In PHP,

//have the speed in bps within the variable $limit
$units = array('bps', 'kbps', 'Mbps', 'Gbps', 'Tbps');
$unit = 0;
while ($limit > 1000) {
    $unit++;
    $limit = $limit / 1000;
}
//Now we'll form the speed with a unit
$speed = $limit . $units[$unit]; 

It would be analogous in any other programming language.

Dear boen_robot,

Thanks for the code, but, from which version it changed ?

regards,

Was it ever different? I thought it was always in bits per second…

If not, then I guess it changed exactly in 6.18, given the change log, which says:

*) api - use the same syntax for property values as is used in ‘print detail’
output, with the exception of numbers, that are not shown with suffixes
(K/M/G/T or bitrate) and are not contracted or separated into digit groups,
and “yes”/“no” values that continue to be reported as “true”/“false”.

Dear boen_robot,

This was i need to know, in previous versions the values return with G/M/K/B, now I’ll change my program to receive the values correctly.

Many thanks again.

Thanks for the code