What programning language contains a PosMod function?

Hi Folks,

What does the function PosMod do and what language is it?

for example:

 dom = PosMod(y + (y \ 4) - (y \ 100) + (y \ 400), 7)

TIA,

July 25th, 2015 1:49pm

Apparently it is a built-in function in Musimat, a C++-like language. PosMod is listed among the Miscellaneous Math Functions. It is described as

    Positive wing of j modulo k.
    PosMod performs modulus arithmetic but returns only the positive wing of modulus values.

whatever that may mean ;-)

Free Windows Admin Tool Kit Click here and download it now
July 25th, 2015 2:16pm

Hi Hans,

I did an internet search and found nothing, so your answer is great.  Now I need to see if I fully understand and can implement and equivalent in VB from the rather short description given in the documentation.

From the above example

dom = PosMod(y + (y \ 4) - (y \ 100) + (y \ 400), 7)

I will be trying something like:

        If (y + (y \ 4) - (y \ 100) + (y \ 400)) >= 7 Then
            dom = (y + (y \ 4) - (y \ 100) + (y \ 400)) - 7
        ElseIf (y + (y \ 4) - (y \ 100) + (y \ 400)) < 0 Then
            dom = (y + (y \ 4) - (y \ 100) + (y \ 400)) + 7
        Else
            dom = (y + (y \ 4) - (y \ 100) + (y \ 400))
        End If

I don't know if you want to go here, but if so, does that make sense to you?

Thanks,

Shane

July 25th, 2015 3:20pm

You could use this custom function in Excel:

unction PosMod(a As Long, b As Long) As Variant
    If b <= 0 Then
        PosMod = CVErr(xlErrValue)
    Else
        PosMod = a Mod b
        If PosMod < 0 Then
            PosMod = PosMod + b
        End If
    End If
End Function

and then use the literal expression from the example:

dom = PosMod(y + (y \ 4) - (y \ 100) + (y \ 400), 7)

Free Windows Admin Tool Kit Click here and download it now
July 25th, 2015 3:47pm

You could use this custom function in Excel:

Function PosMod(a As Long, b As Long) As Variant
    If b <= 0 Then
        PosMod = CVErr(xlErrValue)
    Else
        PosMod = a Mod b
        If PosMod < 0 Then
            PosMod = PosMod + b
        End If
    End If
End Function

and then use the literal expression from the example:

dom = PosMod(y + (y \ 4) - (y \ 100) + (y \ 40

July 25th, 2015 7:43pm

Never mind I solved it:

        If (y + (y \ 4) - (y \ 100) + (y \ 400)) Mod 7 >= 7 Then
            dom = (y + (y \ 4) - (y \ 100) + (y \ 400)) Mod 7 - 7
        ElseIf (y + (y \ 4) - (y \ 100) + (y \ 400)) Mod 7 < 0 Then
            dom = (y + (y \ 4) - (y \ 100) + (y \ 400)) Mod 7 + 7
        Else
            dom = (y + (y \ 4) - (y \ 100) + (y \ 400)) Mod 7
        End If

Thanks,

Shane

Free Windows Admin Tool Kit Click here and download it now
July 25th, 2015 9:40pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics