# $num(x,y) should not truncate decimal numbers to the whole part

**URL:** https://community.mp3tag.de/t/num-x-y-should-not-truncate-decimal-numbers-to-the-whole-part/69643
**Category:** Fixed Bugs
**Tags:** bug-fixed
**Created:** [September 7, 2025, 7:56pm UTC](https://community.mp3tag.de/t/num-x-y-should-not-truncate-decimal-numbers-to-the-whole-part/69643 "2025-09-07T19:56:29Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![e345](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/e/d9b06d/32.png) [@e345](https://community.mp3tag.de/u/e345)
#### Post date: [September 7, 2025, 7:56pm UTC](https://community.mp3tag.de/t/num-x-y-should-not-truncate-decimal-numbers-to-the-whole-part/69643/1 "2025-09-07T19:56:29Z")

</div>

reopening old issue: [[X] $num doesn’t work as described](https://community.mp3tag.de/t/x-num-doesnt-work-as-described/11257)

OS: Windows 10  
mp3tag: 3.31a

According to Docs ( [Scripting Functions – Mp3tag Documentation](https://docs.mp3tag.de/scripting/) ),  
"returns string x interpreted as decimal number, padded with leading zeros from the left up to y digits. It ignores anything from the first non-numeric character, or results in 0 if the string is not numeric."

$num(x,y) should handle decimal numbers, but instead, it truncates the number to the whole value.

Expected: $num(1.5,2) = 01\*\*.5\*\*

Actual: $num(1.5,2) = 01

My Action: $num(%series-part%,2)

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [September 7, 2025, 8:04pm UTC](https://community.mp3tag.de/t/num-x-y-should-not-truncate-decimal-numbers-to-the-whole-part/69643/2 "2025-09-07T20:04:11Z")

</div>

Perhaps "decimal number" is an unlucky term as MP3tag only handles integer numbers.  
(This is also mentioned in the documentation:

## [Arithmetic Functions](https://docs.mp3tag.de/scripting/#arithmetic-functions)

Integer arithmetic only, operations support up to 64 arguments.

```auto

```

In that context $num() works as described: it ignores anything from the first non-numeric character onwards which is the dot in your your example. That leaves only the "1" which is then padded to show 2 digits.

---

<div class="post-metadata">

### Author: ![e345](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/e/d9b06d/32.png) [@e345](https://community.mp3tag.de/u/e345)
#### Post date: [September 7, 2025, 8:17pm UTC](https://community.mp3tag.de/t/num-x-y-should-not-truncate-decimal-numbers-to-the-whole-part/69643/3 "2025-09-07T20:17:40Z")

</div>

> [@ohrenkino](#):
>
> s is also mentioned in the d

Agreed. While I would (obviously) like decimals to be handled, If this is not going to make the priority list, I would suggest changing the docs: "decimal" -\> "integer", to avoid confusion.

---

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [September 8, 2025, 6:18am UTC](https://community.mp3tag.de/t/num-x-y-should-not-truncate-decimal-numbers-to-the-whole-part/69643/4 "2025-09-08T06:18:16Z")

</div>

> [@e345](#):
>
> Expected: $num(1.5,2) = 01\*\*.5\*\*
> 
> Actual: $num(1.5,2) = 01
> 
> My Action: $num(%series-part%,2)

An emulation would be:  
`$num($div($replace(1.5,.,),10),2).$mod($replace(1.5,.,),10)`

---

<div class="post-metadata">

### Author: ![e345](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/e/d9b06d/32.png) [@e345](https://community.mp3tag.de/u/e345)
#### Post date: [September 8, 2025, 10:22pm UTC](https://community.mp3tag.de/t/num-x-y-should-not-truncate-decimal-numbers-to-the-whole-part/69643/5 "2025-09-08T22:22:53Z")

</div>

Thanks @ohrenkino . I updated your suggestion to also handle whole numbers:  
`$ifgreater($strchr(%series-part%,.),0,$num($div($replace(%series-part%,.,),10),2).$mod($replace(%series-part%,.,),10),$num(%series-part%,2))`

---

<div class="post-metadata">

### Author: ![Florian](https://community.mp3tag.de/user_avatar/community.mp3tag.de/florian/32/5759_2.png) [@Florian](https://community.mp3tag.de/u/Florian)
#### Post date: [September 9, 2025, 9:16am UTC](https://community.mp3tag.de/t/num-x-y-should-not-truncate-decimal-numbers-to-the-whole-part/69643/6 "2025-09-09T09:16:13Z")

</div>

> [@e345](#):
>
> $num(x,y) should handle decimal numbers, but instead, it truncates the number to the whole value.

> [@ohrenkino](#):
>
> Perhaps "decimal number" is an unlucky term as MP3tag only handles integer numbers.

Thanks for pointing, I've updated the documentation accordingly.

---

<div class="post-metadata">

### Author: ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)
#### Post date: [October 9, 2025, 9:16am UTC](https://community.mp3tag.de/t/num-x-y-should-not-truncate-decimal-numbers-to-the-whole-part/69643/7 "2025-10-09T09:16:39Z")

</div>

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