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,
Technology Tips and News
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,
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 ;-)
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
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)
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
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