$div decimal places?

Can the $div scripting function be made to return a given number of decimal places? Or can I do something similar with $mod?


Mp3tag scripting language supports integer mathematics only.
So let us see your real world example and maybe we can solve the problem.


OK thanks DetlevD

I want to show the tag size in kB so I need something like $div(%_tag_size_prepended%, 1024). For 1 decimal place I guess I need something like:

$div(%_tag_size_prepended%,1024).$div($mul($mod(%_tag_size_prepended%, 1024), 10), 1024)k

but its not rounding up. Any suggestions?

This might round in the right way:

$ifgreater($mod($div($mul(%_tag_size_prepended%,100),1024),10),4,$div($add(1,$div($div($mul(%_tag_size_prepended%,100),1024),10)),10)'.'$mod($add(1,$div($div($mul(%_tag_size_prepended%,100),1024),10)),10),$div($div($div($mul(%_tag_size_prepended%,100),1024),10),10)'.'$mod($div($div($mul(%_tag_size_prepended%,100),1024),10),10))' KB'

e. g. 672615 to 656.9 KB
e. g. 13648 to 13.3 KB


Wow that seems to work! thanks DetlevD. :smiley: