Help - Search - Members - Calendar
Full Version: Title Formatting Integers
Hydrogenaudio Forums > Hosted Forums > foobar2000 > General - (fb2k)
superdumprob
I've read the manual and I've been playing about for a while trying to get a "percentage of the track that has been played" display in my status bar. Is there any easy way to remove the decimals to just display 1% or 58% or whatever.

This is the basic code:
CODE
$div(%_time_elapsed_seconds%,%_time_total_seconds%)'%'


Very simple I know. I was thinking maybe something like $int(x) could be used to take only the integer value.

Also, I assume $mod(x,y) takes the modulus of x and y...?

Thanks
musicmusic
1. You can use either

$div($mul(%_time_elapsed_seconds%,100),%_time_total_seconds%)'%'

or

$muldiv(%_time_elapsed_seconds%,100,%_time_total_seconds%)'%'

(second is better to use)

2. $mod isnt modulus (at least not modulus as i know it). It works kind of like this, $mod(x,y) e.g. put something as x e.g. $rand() or %_time_elapsed_seconds%, and the range+1 as y. So x will be used to generate a number in 0 to y. (it seems to be -y to y with $rand() )

E.g. $mod(%_time_elapsed_seconds%,5) will reutrn 0,1,2,3,4,0,1,2,3,4... as each second of the song goes by.
superdumprob
Cool, thanks for that musicmusic smile.gif Much appreciated
kode54
QUOTE(musicmusic @ Apr 30 2003 - 10:36 AM)
$mod isnt modulus
Incorrect.

QUOTE
(it seems to be -y to y with $rand() )
That is because $rand() returns anything from 0 to 0xFFFFFFFF, and Tagz works with signed 32-bit integers, so half of those will be negative, and that most certainly will affect the result. (Unless you work with unsigned variables, or force cast the variables to unsigned prior to calculation, such as (unsigned)x % (unsigned)y)
musicmusic
I know how I learned modulus in maths.. i don't see the relation to $mod(), why i said as i know it.. maybe Ive got more to learn in maths, but when plotting graphs, it was related to inverting negative x/y values (producing wierd graphs, especially with quadratics, y=sinx etc.). taking the modulus of a function is written in ||s e.g. |f(x)| or f(|x|). y=|x| looks like a V shaped graph (negative y values made positive). taking the modulus of a single number basically removes the sign, any negative values are made positive (e.g. |15| = 15, |-15| = 15).

If this is the same thing, my mistake, but $mod(-15) returns -15.

about $rand() stuff, yeah i thought it was something like that, but thaks for the explanation.
Canar
QUOTE(musicmusic @ Apr 30 2003 - 11:04 AM)
I know how I learned modulus in maths.. i don't see the relation to $mod(), why i said as i know it..

I believe the correct term is modulo division. Could be wrong. In any case, $div gives the quotient, $mod gives the remainder.
musicmusic
QUOTE(Canar @ Apr 30 2003 - 08:09 PM)
I believe the correct term is modulo division.

maybe? i only know it as modulus., the modulus functions etc. which is what i was taught and what the exam board says.
edit: oh your talking about $mod().. that would make more sense, in which case i was right, now i feel like saying incorrect wink.gif

QUOTE
In any case, $div gives the quotient, $mod gives the remainder.


yeah I guess that is the best explanation smile.gif
LPTB
@musicmusic:
The function you talk about | x | is called Abs() or absolute value of x and is defined as follows:
Abs(x) = |x| = if(x>=0) x else -x
modulus is $mod and is implemented correctly in foobar:
(x mod p) or (x % p) is 't' (integer) such that there exists 'n' (integer): p*n + t = x

P.S. You should take some more classes in math ;-)
superdumprob
I take Mathematics and Further Mathematics at A-Level in the UK and we are taught that |x| means that if x is negative it becomes positive but of the same magnitude and if x is positive it remains positive. We call this the modulus of x. It is what all the maths teachers in the department know this function as and most of them have done a degree in mathematics. Maybe modulus means something different to programmers.

Having said this I looked on dictionary.com for a definition and it stated that:

QUOTE
2.
a) Mathematics. The absolute value of a complex number.
B) Abbr. mod A number by which two given numbers can be divided and produce the same remainder.
c) The number by which a logarithm in one system must be multiplied to obtain the corresponding logarithm in another system.


So actually I think we're all right. smile.gif On our graphical calculators it considers our modulus as Abs (or the absolute value of...) but we have always been told it was called the modulus and fins the magnitude of a given function.

Hmm, I don't think my post helps the debate much, anyway, regardless of what modulus means, I now know what the $mod() function in foobar does and I thank you for the interesting discussion.
musicmusic
QUOTE(LPTB @ Apr 30 2003 - 09:59 PM)
@musicmusic:
The function you talk about | x | is called Abs() or absolute value of x and is defined as follows:
Abs(x) = |x| = if(x>=0) x else -x
modulus is $mod and is implemented correctly in foobar:
(x mod p) or (x % p) is 't' (integer) such that there exists 'n' (integer) n*p + t = x

P.S. You should take some more classes in math ;-)

hehe.. seriously that is how it is in maths, or maybe maths in england (i am still doing the course, i have my textbooks etc.) .. and a google search on "modulo division" yeilds results describing $mod..

With a search for "modulus function", a random page i found is this:
http://www.mathsdirect.co.uk/pure/purtutfunmod.htm

Ironically, most of the results are UK sites.

Whilst microsoft's "modulus" is this:

http://msdn.microsoft.com/library/default...._(M-P)_1465.asp

well i guess that is what you get with specialist/subject language, one is correct mathematically whilst the other regarding programming or something like that.. I'll just say mathes modulus now..

Edit: Hmm i guess superdumprob has found the answer. BTW what is further maths like? I do Pure + Mech.
LPTB
Well it's only a name BUT it's still important and you can safely tell your teachers in the UK that they are wrong, just to make a point look here:

http://mathworld.wolfram.com/Modulus.html

It's a kind of a mathematical dictionary which agrees with dictionary.com (and me ;-) )

and by absolute value (modulus of complex) they don't mean positive(z) but rather:
if 'z' is complex then z=a*i + b => modulus (z) = | z | = sqrt(a^2 + b^2) (and only in complex).
musicmusic
QUOTE(LPTB @ Apr 30 2003 - 10:29 PM)
It's a kind of a mathematical dictionary which agrees with dictionary.com (and me ;-) )

Erm.. didnt dictionary.com agree with all of us? wink.gif

Anyway, I know there is more to it than just taking the positive value of a number, don't know about what you posted, its not what I learn and so I don't feel like confusing myself.

BTW my original post was to superdumprob and he would have know what i was talking about and it seems he thought the same.. anyway I think we have had enough about modulus, we know it has different meanings, lets leave it at that.
LPTB
Oh well, just tell your teachers. (confusing young minds tsk tsk tsk)
superdumprob
Indeed musicmusic.

LPTB:
QUOTE
The word modulus has several different meanings in mathematics with respect to complex numbers, congruences, elliptic integrals, quadratic invariants, sets, etc.


Notice the etc. The modulus we use could be some other modulus, I will enquire tomorrow.

musicmusic: In single maths I've done modules Methods, Pure 1 and Mechanics 1 at AS and Pure 2, Pure 3 and Stats 1 at A2. In further maths I've done modules Pure 6, Mechanics 2 and Discrete 1 at AS and Pure 4, Pure 5 and Stats 2 at A2. So basically I've done a pure a-level like you and then an applied one but with a mix of stats mechanics and discrete. Apparently this year there are only 3000 further mathematicians across the country whereas last year there were 10000. sad.gif I do Physics as well. I did do Chemistry but it wasn't so interesting and not worth the effort. I would prefer to do Pure and Mechanics (I thought there were only four mechanics modules?) A-levels instead though. I love mechanics. smile.gif

Have fun.

EDIT: I've just found this on that website LPTB linked to... Absolute Value

It's called the absolute value but the notion is identical to the modulus. I'll still ask them why they call it the modulus when it's actually the absolute value.
musicmusic
QUOTE(LPTB @ Apr 30 2003 - 10:44 PM)
Oh well, just tell your teachers. (confusing young minds tsk tsk tsk)

You haven't met my pure math teacher.. its not worth the effort

superdumprob: Hmmm a lot of mathes wink.gif I am doing P1 + P2 + M1 at AS, will do M2 + M3 + P3 at A2. I like Mech, pure is a lot to take in, especially things like trig in P2 :/

I can take up further maths as an AS next year if I want to, but its doubful..
superdumprob
My teachers are fantastic, I have two for further and two for single, but one of them (who is unfortunately retiring at the end of this year, but at least it won't affect me) teaches me in both. Our further maths group only has five people in it which is good in a sense.

Where are you going to Uni? If you are going to Uni that is. I've put down Warwick (As in Maths and Physics and a B in Further Maths to study a 4yr MPhys in Mathematics and Physics) as my firm choice and Nottingham (A in Maths, B in Physics, C in Further Maths to study a 4yr MSci in Mathematical Physics) as my insurance. Hopefully I will get the grades to get into Warwick. I should get three As really if I do a little bit of work.
musicmusic
I think we are taking this thread off-topic wink.gif But yes i (obviously) intend to go to uni, but I really dont know where yet (or what course) sad.gif I really should think about these things, but I really would rarther wait until I have my AS results. BTW i meant Pure Maths with Mech, not as separate subjects.

Edit:
QUOTE
EDIT: I've just found this on that website LPTB linked to... Absolute Value

Yeah the beginning is pretty much like in my P2 book, without sgn(x) stuff.. maybe we (uk) are alone with our definition of modulus..
teetee
QUOTE(LPTB @ Apr 30 2003 - 09:29 PM)
Well it's only a name BUT it's still important and you can safely tell your teachers in the UK that they are wrong, just to make a point look here:

http://mathworld.wolfram.com/Modulus.html

It's a kind of a mathematical dictionary which agrees with dictionary.com (and me ;-) )

and by absolute value (modulus of complex) they don't mean positive(z) but rather:
if 'z' is complex then z=a*i + b => modulus (z) = | z | = sqrt(a^2 + b^2) (and only in complex).

This is the key page to take note of - if you read it carefully it is saying that there are a number of different meanings of the word modulus in maths. It is usually possible to work out the meaning from the context.

There are 5 uses referred to on this page but the two you are debating about are the following:
modulus of a congruence (this is the case where people want the remainder of a division)
modulus of a complex number (absolute value of a complex number)

You might note that in the first case the word modulus actually refers to the number you are dividing by rather than the actual remainder despite how it appears from the programming language syntax.

You should also note that a complex number is simply one which contains an optional real part and an optional imaginary part, therefore real numbers are actually a subset of complex numbers and so modulus in the |-a|=a sense are application of the second case despite there being no obvious imaginary part to a. (think of it as a+0j)

I hope that is clear! If not I suggest you carefully read the following three pages again and talk to your teachers (you won't be telling them they are wrong - just that you aren't clear on the two distinct uses of the word modulus in maths):
Modulus
Complex Modulus
Congruence Modulus

I suggest for now that you ignore the other three uses of the word modulus in mathematics as you are unlikely to need to come across them unless you take maths (or possibly engineering) at uni.

My qualifications? Engineering and Comp student @ Oxford
p.s. Further maths is useful if you are going into a science degree but only to give you a head start on the early stuff, all the courses assume no more than single maths A level at the beginning.
LPTB
QUOTE
so modulus in the |-a|=a sense are application of the second case despite

Despite different definitions of modulus in different branches of math there is NO modulus definition for a real number other than congruence which is defined for integers (or even only N); You can define your own meanings to any given function, so you could define $cat(x) to be e'th power of x, that's all nice and dandy but you would have to explain what $cat means first. Absolute value is defined for real numbers and is the function you reference.
teetee
QUOTE(LPTB @ Apr 30 2003 - 10:59 PM)
QUOTE
so modulus in the |-a|=a sense are application of the second case despite

Despite different definitions of modulus in different branches of math there is NO modulus definition for a real number other than congruence which is defined for integers (or even only N); You can define your own meanings to any given function, so you could define $cat(x) to be e'th power of x, that's all nice and dandy but you would have to explain what $cat means first. Absolute value is defined for real numbers and is the function you reference.

Actually Real numbers are a subset of Complex numbers for which the Imaginary part is zero.

e.g. if a complex numbers is represented by x+yi (or x+yj in engineering) then a real number x is the complex number
x+yi where y=0 (think about this for a moment if it isn't clear)

Therefore there is a definition of modulus for Real numbers which isn't congruence. It is the definition of complex modulus.
If you find the complex modulus of the number x+0i you will find that it is the absolute value of x+0i:

sqrt(x^2 + 0^2) = abs(x)
sqrt((-x)^2 + 0^2) = abs(x)

This is simply a result of the square of a negative number being equal to the square of the positive version.
x^2 = (-x)^2
You must have used this result in other areas of maths.

What I am saying is that it is wholly consistent with the definition of complex modulus. Relabelling it as absolute value in the case of Real numbers is simply a way of making it clear what the result is in that case.
LPTB
QUOTE
Actually Real numbers are a subset of Complex numbers for which the Imaginary part is zero.

true

QUOTE
Therefore there is a definition of modulus for Real numbers which isn't congruence. It is the definition of complex modulus.

Incorrect, this only makes sense when talking about the Reals as a SUBSET of C not as a field by itself. R as a field has no definition for modulus; this thread started with foobar formatting and given foobar does not (yet) incorporate complex numbers it makes no sense to talk about modulus as an absolute value.
teetee
QUOTE(LPTB @ May 1 2003 - 10:49 AM)
QUOTE
Actually Real numbers are a subset of Complex numbers for which the Imaginary part is zero.

true

QUOTE
Therefore there is a definition of modulus for Real numbers which isn't congruence. It is the definition of complex modulus.

Incorrect, this only makes sense when talking about the Reals as a SUBSET of C not as a field by itself. R as a field has no definition for modulus; this thread started with foobar formatting and given foobar does not (yet) incorporate complex numbers it makes no sense to talk about modulus as an absolute value.

"yet" biggrin.gif

while I agree that this has gone off topic with respect to foobar itself I would continue to disagree with you about modulus smile.gif. hopefully we will be allowed to continue to debate without reprisal/topic closing from the moderators!

I think it makes perfect sense to talk about modulus as an absolute value of a Real number. It is a function mapping a single Complex number to a single Real number. It is valid for the whole set/field of Complex numbers. As you have already acknowledged, Real numbers are a subset of Complex numbers. Therefore the function modulus is valid for the whole set/field of Real numbers.

The function modulus (in the remainder sense) is a function mapping two numbers (supposedly integers but people liberally use it on Reals as well) to a single number.

As I said earlier, the context of the use of the word modulus is usually sufficient to tell which of the two definitions is pertinent. ie "modulus of x" = abs(x), "x modulus y" = remainder(x/y)

QUOTE
You can define your own meanings to any given function, so you could define $cat(x) to be e'th power of x, that's all nice and dandy but you would have to explain what $cat means first. Absolute value is defined for real numbers and is the function you reference.

I could equally say that Remainder is defined for (integer) division and it is the same as the function $mod(x,y) used in foobar. This wouldn't invalidate the use of the word Modulus to describe the function, I would just be saying "I have another word for that".
LPTB
QUOTE
while I agree that this has gone off topic with respect to foobar itself I would continue to disagree with you about modulus . hopefully we will be allowed to continue to debate without reprisal/topic closing from the moderators!

We are on borrowed time.

QUOTE
It is a function mapping a single Complex number to a single Real number.

This is completely false, | a + bi | = | ai + b | while the two numbers are not equal, modulus is function (in C or any other vectorspace) where a _set_ or more precisely a representative of the _set_ is mapped to a single real number.

I'm quite tired of this discussion, you could use modulus in the sense of absolute value for any field or even a herd of elephants, it doesn't change the fact that modulus in integers is meant to be congruence.
teetee
QUOTE(LPTB)
QUOTE
It is a function mapping a single Complex number to a single Real number.

This is completely false, | a + bi | = | ai + b | while the two numbers are not equal, modulus is function (in C or any other vectorspace) where a _set_ or more precisely a representative of the _set_ is mapped to a single real number.


I didn't say one-to-one mapping.

QUOTE(LPTB)
you could use modulus in the sense of absolute value for any field or even a herd of elephants, it doesn't change the fact that modulus in integers is meant to be congruence.

We are just talking about common-usage here which is subjective. I haven't been trying to say this isn't true, I have been trying to say that modulus in the sense of absolute value is valid also (something which apparently wasn't accepted earlier on in the thread):
QUOTE(LPTB)
Well it's only a name BUT it's still important and you can safely tell your teachers in the UK that they are wrong


You also say
QUOTE(LPTB)
I'm quite tired of this discussion

Fair enough, let's "agree to disagree".
superdumprob
Hello people,

I asked one of my teachers why the exam board calls it the modulus when it's the absolute value and he said that it's due to the notation being called the modulus and in maths the functions carried out are used interchangably with regard to the context of the question, generally. Hence modulus (|f(x)|) can mean a number of things. Anyway, I think we should end this thread now. smile.gif

Thanks
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.