Skip 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.

Number Formating

Featured Replies

Hi everyone,

I have a calculation field that has text and numbers in it. It is basically a conversion field. The user enters one value in the "Qty Convert" field and then chooses the unit in the "from" field and the unit in the "to" field. The calc field displays something like:

100 Kilograms = 3527.396198 Ounces

My problem is that I have to make the calc a text field not a number field so I can't format the number to include the thousand separator. I have a fairly long calculation to do this but is there an easier way? I would also like to add a million separator in the unlikely event that it is needed.

Any help is greatly appreciated

Use four fields: a number field (for the original quantity, formatted with the thousands separator), a text field for the From units, a text field for the To units, and a number field for the result (formatted with the thousands separator).

  • Author

Thanks for replying so quickly,

I tried that but then I have a spacing problem. Although it is just Aesthetic it is annoying. I have to make the number fields big enough to accomodate 7 places on both sides of the decimal point and the slide left doesn't help. Is there another way to make it more continuous?

There was a discussion of this recently here. Check Ugo Di Luca's first post.

HTH,

Jerry

  • Author

Thank you guys this is great

I used Di Luca's Calc and it worked great. But just to cause touble is there a way to eliminate the unused zeros? I want to be able to have 7 digits past the decimal but only when they are needed.

Thanks again

Try substituting the last portion of the calc (starting with "Choose( Precision = 0") with

Let( P = Min( Precision; Length(Substitute( GetAsNumber( "." & Right( Number; Length(Number) - Position( Number & Case( not PatternCount( Number; "." ); "." ); "."; 0; 1 ) )); "."; "" )) );

Choose( P = 0 ; "." &

Right( 10 ^ P & Abs( Round( Number ; P ) )

* ( 10 ^ P ) ; P ))

)

Perhaps it can be shorter? Instead of the original

...

Choose( PRECISION = 0 , ...

use

...

Choose( (PRECISION <= 0) or not Mod( Number , 1 ) , ...

Right. I was thinking that Mod might return screwy results here, but I guess that was Int I was remembering.

In that case, ditch the above suggestion and go with

Let( P = Min( Precision; Length(Mod( Number; 1 )) - 1 );

Choose( P = 0; "." &

Right( 10 ^ P & Abs( Round( Number ; P ) )

* ( 10 ^ P ) ; P ))

)

  • Author

Those work great for anything 7 decimal places and less. But anything with more rounds off and leaves the 7 zeros. I can't thank you guys enough for your time, I really appreciate it.

I still don't get it. This, IMHO, is all the modification required:

Choose( (PRECISION <= 0) [color:"red"] or not Mod( NUMBER , 1 ) , "." &

Right( 10^PRECISION & Abs( Round( NUMBER , PRECISION ) )

* ( 10^PRECISION ) , PRECISION ))

He doesn't want the trailing zeroes, which is why I used a dynamic precision.

Okay, this one seems to work well.

Let([ M = Mod( Number; 1 ); P = Min( Precision; Length(Round( M; Precision )) - 1 ) ];

Choose( P <= 0; "." &

Right( 10 ^ P & Abs( Round( Number; P ) )

* ( 10 ^ P ) ; P ))

)

Oh. Sorry, I completely misunderstood. I thought he wanted to cut off the trailing zeroes in case the number was an integer.

P.S. I still think it should be P <= 0.

I couldn't figure out why until I entered some negative precisions. Without it, the decimal point appears at the end of an integer. Good call. I modified the calc above to include it.

I also broke negative Number values. It's fixed now.

Here's another variant (you're not the only one bored):

Choose ( Precision <= 0 ; "."

&

Middle (

Abs ( Mod ( Round ( Number ; Precision ) ; 1 ) ) ;

2 ; Precision + 1

) )

or even simpler:

Choose ( not Mod ( Number ; 1 ) ;

Abs ( Mod ( Round ( Number ; Precision ) ; 1 ) )

)

Excellent! I hate it when I make things too difficult.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.