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 6555 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Greetings,

I need to get the values on the left and right side of a decimal. I have the left side figured out via the truncate function, however, how do I get the value on the right side of the decimal?

Left Side Calc=Truncate(TOTAL_COST, 0)

Ride Side Calc= :)

Any help would be greatly appreicated.

Thanks in advance!

Posted (edited)

Whole number = Int ( numberField )

decimal portion = Mod ( numberField , 1 )

:wink2:

UPDATE: If you want to drop the decimal, just add *100 at the end of the decimal portion. Of course these should be number fields.

Edited by Guest
Added update
Posted

I was unsure of the result required; whether it was to 'write out' the number or what. If the number is 1.22 and only 22 is requested then Mod ( numberField , 1 ) will produce .22 but Mod ( numberField , 1 ) * 100 will produce 22. There are other ways but that's what came to me quickly. :wink2:

Posted (edited)

You were right - I was in a hurry heading out the door. 3.1415926535897932 would break. I appreciate the catch! How about:

Mod( Round( numberField , 2 ) , 1 ) * 100

It still lacks elegance ...

Edited by Guest
Posted (edited)

Could also use...

Left( numberField ; Position( numberField ; "." ; 1 ; 1 ) - 1 )

...but meh

EDIT: Left( numberField , If( PatternCount( numberField , "." ) , Position( numberField , "." , 1 ; 1 ) - 1 , numberField ) )

Edited by Guest
kind of long winded and definitley not recommended but it still works
Posted (edited)

We're working on the remainder, Genx. That produces the integer. And they are on vs. 6 so switch the semi-colons. I prefer not to mix number and text functions if I can help it. I was looking for straight math. :wink2:

UPDATE: There are many fun ways to go here! I like these puppies!

Edited by Guest
Posted

Depends on the purpose. If it's currency (as it seems to be in this case), that would work well to extract the (whole) cents portion of the amount - provided the amount is not negative.

How about:

Right ( Round ( number * 100 , 0 ) , 2 )

Posted (edited)

Yep, I'd conceed mixing number and text functions if it's leaner and just as clear. Nice! Again, change the semi-colons to commas for vs. 6. I'm glad you mentioned the decimal length; that's the kind of omission which can bite us and something I should have thought of!

Edited by Guest
added "Nice!"
Posted (edited)

Thanks for the feedback, it turns out that there will only be two decimal values for my result so *100 will work just fine.

Hold on! It isn't the result we're concerned with. If your number field has more than two decimals (and I'm not talking about what displays in Field Format), then my FIRST calc will break! Listen to Comment here. His is also more efficient! :wink2:

Edited by Guest
Posted

OK, no text functions:

Mod ( Round ( Abs ( number * 100 ) , 0 ) , 100 )

What does that give us that this one doesn't, Michael?

Mod( Round( numberField , 2 ) , 1 ) * 100

I can see no difference in my tests. Now this stuff brings a flush to my cheeks! I could play with these puppies all day!

Posted

It's the same thing, except the Abs(). IIRC, you don't need the Abs() in version 6, but it's better to plan ahead.

BTW, if rounding, one should apply similar rounding before extracting the integer portion - otherwise 0.995 will return 0 on both.

Posted

Good points. I see mine handles negatives as well. It is interesting to re-combine these functions and observe the subtle differences between them.

Posted (edited)

Yikes! I converted the vs. 6 to vs. 8 and my calc changed from -23 to 77!! Is this the Abs() piece? I must figure this out!

IIRC, you don't need the Abs() in version 6, but it's better to plan ahead.

Now your comment (smile) fits ...

Edited by Guest

This topic is 6555 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.