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.

Formatting decimal numbers to fractions

Featured Replies

  • Author

I have a question about formatting numbers.

Is there a way to format a number such that if it is not a whole integer it will display as

a number plus a fractional remainder?

To complicate this further, I would like to constrain the fractional result to eighths (1/8) or sixteenths (1/16).

For example: 1.625 would show up as (1-5/8) and 1.685 would show up as (1-11/16).

If the fractional result was other than an eighth or a sixteenth I would like to have the number round to those type of fractions.

If anybody could help me here I would sure appreciate it.

Thanks,

Jarvis

I have a question about formatting numbers.

Is there a way to format a number such that if it is not a whole integer it will display as

a number plus a fractional remainder?

To complicate this further, I would like to constrain the fractional result to eighths (1/8) or sixteenths (1/16).

For example: 1.625 would show up as (1-5/8) and 1.685 would show up as (1-11/16).

If the fractional result was other than an eighth or a sixteenth I would like to have the number round to those type of fractions.

If anybody could help me here I would sure appreciate it.

Thanks,

Jarvis

I hope this is correct:

Let ( [

fraction = Mod ( Number ; 1 ) ;

sixteenths = Round ( fraction * 16 ; 0 )

] ;

Case ( Int ( Number ) ; Int ( Number) )

&

Case ( Int ( Number ) and sixteenths ; "-" )

&

Case (

sixteenths ; Choose ( Mod ( sixteenths ; 2 ) ;

sixteenths / 2 & "/8" ;

sixteenths & "/16" )

)

)

I hope this is correct:

Let ( [

fraction = Mod ( Number ; 1 ) ;

sixteenths = Round ( fraction * 16 ; 0 )

] ;

Case ( Int ( Number ) ; Int ( Number) )

&

Case ( Int ( Number ) and sixteenths ; "-" )

&

Case (

sixteenths ; Choose ( Mod ( sixteenths ; 2 ) ;

sixteenths / 2 & "/8" ;

sixteenths & "/16" )

)

)

  • Author

Comment,

Thanks for your help........so far.

The code you recommended does a good job of parsing the decimal into itself + it's fractions

but it needs a little more embellishment.

for example:

7.3125 shows up as 7516 which is what I asked for

But if possible..... could you tell me how to make this read 7 5/16

I need a space between the 7 & 5 and a / between 5 & 16.

If I was a little smarter I could probably stare at your code and figure this out.

But I'm not and you are.

Any more suggestions?

Thanks,

Jarvis

  • Author

Comment,

Thanks for your help........so far.

The code you recommended does a good job of parsing the decimal into itself + it's fractions

but it needs a little more embellishment.

for example:

7.3125 shows up as 7516 which is what I asked for

But if possible..... could you tell me how to make this read 7 5/16

I need a space between the 7 & 5 and a / between 5 & 16.

If I was a little smarter I could probably stare at your code and figure this out.

But I'm not and you are.

Any more suggestions?

Thanks,

Jarvis

1. Is your calculation defined to return a TEXT result?

2. If you want a space, instead of - , replace the "-" in the formula with " " (that's a space surrounded by quotes).

1. Is your calculation defined to return a TEXT result?

2. If you want a space, instead of - , replace the "-" in the formula with " " (that's a space surrounded by quotes).

  • Author

Comment,

You were right. My calculation was not set up to result in text. When I changed that part everything worked.

Except for the part where I neglected to allow for quarters (1/4 & 3/4) as a possible end result.

Where would I stick this in the equation?

Jarvis

PS: Thanks for your patience.

  • Author

Comment,

You were right. My calculation was not set up to result in text. When I changed that part everything worked.

Except for the part where I neglected to allow for quarters (1/4 & 3/4) as a possible end result.

Where would I stick this in the equation?

Jarvis

PS: Thanks for your patience.

You keep changing the specs. Earlier you said "I would like to constrain the fractional result to eighths (1/8) or sixteenths (1/16)".

It's not that I am complaining. Well, I am, but the point is - when you make something for a specific purpose, then adapt it, it may end up being less efficient than making it for a general purpose to begin with. So, with this caveat, try:

Let ( [

fraction = Mod ( Number ; 1 ) ;

sixteenths = Round ( fraction * 16 ; 0 )

] ;

Case ( Int ( Number ) ; Int ( Number) )

&

Case ( Int ( Number ) and sixteenths ; "-" )

&

Case (

sixteenths ; Choose ( Mod ( sixteenths ; 4 ) ;

sixteenths / 4 & "/4" ;

sixteenths & "/16" ;

sixteenths / 2 & "/8" ;

sixteenths & "/16" )

)

)

You keep changing the specs. Earlier you said "I would like to constrain the fractional result to eighths (1/8) or sixteenths (1/16)".

It's not that I am complaining. Well, I am, but the point is - when you make something for a specific purpose, then adapt it, it may end up being less efficient than making it for a general purpose to begin with. So, with this caveat, try:

Let ( [

fraction = Mod ( Number ; 1 ) ;

sixteenths = Round ( fraction * 16 ; 0 )

] ;

Case ( Int ( Number ) ; Int ( Number) )

&

Case ( Int ( Number ) and sixteenths ; "-" )

&

Case (

sixteenths ; Choose ( Mod ( sixteenths ; 4 ) ;

sixteenths / 4 & "/4" ;

sixteenths & "/16" ;

sixteenths / 2 & "/8" ;

sixteenths & "/16" )

)

)

  • Author

Thanks Comment!

It works perfect!

Jarvis

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.