Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 5795 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

BTW, I began thinking further ... Mod ( numField ; 1 ) will not work for minus numbers. I believe it will work if there aren't any but I wanted it to be considered in your decision.

Posted

If number can be negative, you could use either:

Mod ( Abs ( number ) ; 1 )

or:

Mod ( number ; Sign ( number ) )

depending on whether you want the result to inherit the sign of the input or not.

Posted (edited)

Ah. Sign(). I like that the best because it doesn't suppose ... it simply truncates and leaves the value as before (but only the remaining) portion. I also wanted to ask if it should be rounded but I assumed that was overkill ... :king:

UPDATE: Yes! This is best because it works both ways!

Edited by Guest
Posted

There's one pitfall with the 'Mod ( number, Sign ( number ) )' method:

Sign can return 0, which, if it does, Mod would be attempting to divide by 0, which is undefined. Of course this is a special case; however, this is precisely what we must always be worried about, i.e. the special cases!

Well, excuse me. I just tried using the Mod & Sign calculation and it correctly calculated the value that scottvaughan wanted, e.g.:B

number = 27.385 ==> calc. = .385

number = -17.129 ==> calc. = -.129

number = 0 ==> calc. = 0

That concerns me because FileMaker is making a non-standard choice for a mathematical function. If one created a calculation that resulted in dividing by zero, most software would display some special value like, "#undefined#" or the software would crash. Why would we want FileMaker to do something different?

Sheeesh. I just did some more testing and FileMaker gives a completely incorrect answer when mixing positive and negative:

Mod ( -17.129, 1) ==> .871

Sounds like a bug to me.

Posted

It's not a bug at all, but an intentional (and entirely commendable, IMHO) choice:

http://filemaker.custhelp.com/cgi-bin/filemaker.cfg/php/enduser/std_adp.php?p_faqid=721

Too bad the description of the function in the help remains outdated:

http://fmforums.com/forum/showpost.php?post/292075/

This topic is 5795 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.