March 10, 200916 yr I have a calculation where the result is 1.5. I need the value in my field to only be .5. How do I truncate or format the field so it only recognized the decimal point value.
March 11, 200916 yr 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.
March 11, 200916 yr 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.
March 11, 200916 yr 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 ... UPDATE: Yes! This is best because it works both ways! Edited March 11, 200916 yr by Guest
March 11, 200916 yr 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. 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.
March 11, 200916 yr 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/
Create an account or sign in to comment