Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Rounding in NumToText - how can I prevent this?

Featured Replies

I am working with credit card numbers. I want to limit who can see the entire number, and so after it's been entered and validated, people should see only the FIRST 4 digits, plus 3 dots, plus the LAST 5 digits.

I have defined a text field calculation so: Left(creditcardtext, 4) & "..." & Right(creditcardtext, 5)

Here's what I get:

1234123412341234 the original credit card number, in number field

but when I use the Left and Right functions:

1234...41230 Left(CCnum, 4) & "..." & Right(CCnum, 5)

so, I thought I'd check what the number field looks like as a text field. Sure enough,

1234123412341230 CCtext calc'd as NumToText (CCnum) AND

1234...41230 Left(CCtext, 4) & "..." & Right(CCtext, 5)

So my question is - why does the number get rounded when converted to text? How can I prevent this?

-mlplouff

Hello mlplouff,

Your problem stems from the fact that in FileMaker:

"all numbers are converted to 64 bit extended floating point with precision of 15 digits including both before and after decimal positions"

(ref: FMI TechInfo KnowledgeBase article no 107472, "Technical Specifications Of FileMaker Pro 5.5", http://www.filemaker.com/ti/107472.html )

Thus, all numbers and numeric results of a precision greater than 15 are therefore rounded to 15 significant figures, whenever they are referenced or rendered by calculation.

This is one of several reasons why credit card numbers are normally entered and stored as text. Another reason is that their *meaning* is not numeric, even though they may contain only numerals.

Text fields are for alphanumeric strings of all kinds - and credit card 'numbers' are an alphanumeric string (rather than a number value) which just happens to contain no alpha characters. So, for example, you are rather less likely to start performing arithmetic with them than you are to apply text manipulation functions (such as Left( ) and Right( ) for example...).

I'd therefore recommend that you change your CCnum field to a text field. In the unlikely even that you find to need to start doing arithmentic with it, you can reference the field using TextToNum(CCnum) (though of course, as soon as you do, the rounding to a prescision of 15 will again be applied). wink.gif

  • Author

Thanks. Simple fix, and I will remember about the precision.

- mlplouff

In the unlikely even that you find to need to start doing arithmentic with it...
not so unlikely if you calc a checksum to validate. but you would do this arithmetic on substrings only ...

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.