Author Topic: arithmic functions $Add $Sub $Mul $Div  (Read 1932 times)

hiccup

  • Sr. Member
  • ****
  • Posts: 7781
Some questions about the arythmic arithmetic functions that were added sometime ago. (which introduction I seem to have missed)

1.
I am wondering about the 'failed' error messages when tags are empty.
Will virtual tags that use one of these functions need to be extended somehow so to avoid this, or could something maybe be done internally within MB?



2.
These four new functions do not appear in the Template Editor.
I am guessing they should?



2b.
Are there perhaps other more-recently added functions available that are currently not in the template editor?

And, not being a certified number-cruncher but still wondering:
Why does line 3 has 'NaN' as the outcome?
Shouldn't it say '0' just like line 4?
Last Edit: January 11, 2022, 06:24:57 PM by hiccup


hiccup

  • Sr. Member
  • ****
  • Posts: 7781
"NaN" means "not a number."
Ah ok.

But when I look up what the outcome of dividing by zero should be called (in English), some say it is 'undefined' (since it can not be defined), others say it is 'infinite' (hence the infinity symbol)
'NaN' is probably a third way of saying pretty much the same?

But what I was mainly wondering about looking at my simple test:
Why does 2 divided by 0 output:  'infinity', but 0 divided by 0:  'NaN'?
Shouldn't they output the same? (for consistency’s sake)

hiccup

  • Sr. Member
  • ****
  • Posts: 7781
So, I have had an Amazing Discovery/Revelation:

While I have always been aware that Boroda's Additional Tagging & Reporting Tools plugin had additional functions available that MusicBee doesn't (such as these four arithmetical functions), it never dawned upon me that as soon as you install this plugin, you can use these additional functions for MusicBee's virtual formulas.
Without the need of even opening or looking at the AT&RT plugin.

So this is why these functions don't show in MusicBee's Template Editor.
Please tell me that I am not the only one that never knew this?

P.S.
I have updated this listing of functions for virtual tags, adding this newly acquired knowledge.

The Incredible Boom Boom

  • Sr. Member
  • ****
  • Posts: 1269
But when I look up what the outcome of dividing by zero should be called (in English), some say it is 'undefined' (since it can not be defined), others say it is 'infinite' (hence the infinity symbol)
'NaN' is probably a third way of saying pretty much the same?

0/0 should never be undefined, it should always be NaN.
Undefined and NaN have different meanings. "Undefined" means "no value assigned." "NaN" is a value that means "not a (valid) number."

Quote
But what I was mainly wondering about looking at my simple test:
Why does 2 divided by 0 output:  'infinity', but 0 divided by 0:  'NaN'?
Shouldn't they output the same? (for consistency’s sake)

Some programming languages define numbers greater than zero divided by zero as "infinity" (not accurate) as opposed to "undefined" (scientifically mathematically accurate) so errors and exceptions won't be thrown.
Depending on the language and program, you'll likely want to apply the return values of NaN, infinity or undefined in different ways, so it's necessary to distinguish among them.

So, I have had an Amazing Discovery/Revelation:

While I have always been aware that Boroda's Additional Tagging & Reporting Tools plugin had additional functions available that MusicBee doesn't (such as these four arithmetical functions), it never dawned upon me that as soon as you install this plugin, you can use these additional functions for MusicBee's virtual formulas.
Without the need of even opening or looking at the AT&RT plugin.

So this is why these functions don't show in MusicBee's Template Editor.
Please tell me that I am not the only one that never knew this?

Yes, I love this part about the plugin. My setup relies completely on the extra functions he's incorporated. Whenever @boroda goes on his long hiatuses I freak out and hope future MB updates don't implement something that breaks it. 😬
Last Edit: January 13, 2022, 06:42:26 PM by The Incredible Boom Boom

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
If the arithmetic functions are being used a lot i can include native support in MB. Let me know which ones you use

The Incredible Boom Boom

  • Sr. Member
  • ****
  • Posts: 1269
If the arithmetic functions are being used a lot i can include native support in MB. Let me know which ones you use

That would be awesome!
Good riddance to anyone who complains about MB and the support given!
For now, things are a-ok, so it's not a priority to implement them, but I use these everywhere...
basic arithmetic

    name
     syntax
Add$Add(number1,number2)
Sub$Sub(number1,number2)
Mul$Mul(number1,number2)
Div$Div(number1,number2)

other arithmetic

    name
     syntax
Abs (absolute)$Abs(number)
Mod (modulus)$Mod(number1,number2)

And the non-arithmetic functions I rely on are...
Quote
Boolean operations

    name
     syntax
Not$Not(parameter)

string operations

    name
     syntax
Len$Len(string): length of string
CutLeft$CutLeft(string,count)
CutRight$CutRight(string,count)

time and date

    name
     syntax
AddDuration$AddDuration(duration1,duration2)
AddDurationToDateTime$AddDurationToDateTime(datetime,duration)
Now$Now()
NumberOfDays$NumberOfDays(datetime1,datetime2)
SubDateTime$SubDateTime(datetime1,datetime2)
SubDuration$SubDuration(duration1,duration2)
SubDurationFromDateTime$SubDurationFromDateTime(datetime,duration)

hiccup

  • Sr. Member
  • ****
  • Posts: 7781
If the arithmetic functions are being used a lot i can include native support in MB. Let me know which ones you use
For now, things are a-ok, so it's not a priority to implement them, but I use these everywhere...
To be honest, personally I am not using these functions an awful lot, but I think that the ones that Boom Boom filtered out and is suggesting make sense to possibly be available by default.

hiccup

  • Sr. Member
  • ****
  • Posts: 7781
…great explanation…
Thanks for this. I feel smarter after reading what you wrote ;-)

Another reason why I brought this up, is that I was thinking that it might be better if for any case a specific number could not be output, the output would be the same.
For the purpose of using virtual tags in MusicBee, not needing to worry if you will have to adjust a formula to handle different outputs such as:
'NaN' / '∞' / 'error, exception has been thrown' etc.

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
https://getmusicbee.com/patches/MusicBee35_Patched.zip

these have been added natively
Code
$Abs(<field>)
$Add(<field>,<field>)
$CutLeft(<field>,length)
$CutRight(<field>,length)
$Div(<field>,<field>)
$Mod(<field>,<field>)
$Mul(<field>,<field>)
$Not(logical-condition)
$Sub(<field>,<field>)

The Incredible Boom Boom

  • Sr. Member
  • ****
  • Posts: 1269
https://getmusicbee.com/patches/MusicBee35_Patched.zip

these have been added natively
Code
$Abs(<field>)
$Add(<field>,<field>)
$CutLeft(<field>,length)
$CutRight(<field>,length)
$Div(<field>,<field>)
$Mod(<field>,<field>)
$Mul(<field>,<field>)
$Not(logical-condition)
$Sub(<field>,<field>)

🥳🥳🥳
How does this work with @boroda's plugin? I'm guessing long ago he implemented some type of functionality that would disable his functions if you included them at some point?

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312