Salesforce and other SMB Solutions are coming soon. ×

# Converting Centimeters to Inches ## Recommended Posts  Hello.

I'd like to create a calculation field that converts centimeters to inches with a maximum of 3 decimal places. I set up the field like this:

Round (Centimeter_Field * 0.393700787;3)

It would be very helpful if I could limit the results to standard inch increments, like:

1/2 inch (.5)

1/4 inch (.25)

3/8 inch (.375)

5/8 inch (.625)

And make the results round up OR down to the closest standard increment, so that:

12.376 rounded to 12.375

12.374 rounded to 12.375

12.555 rounded to 12.5

12.430 rounded to 12.5

Is there a way to accomplish this?

Julia

##### Share on other sites  try (result is text)

```Let
( [
inchfull = Round (centi * ,393700787;4) ;
whole = Truncate ( inchfull ; 0 ) ;
fraction = inchfull - whole ;
precision =
Case
(
fraction ≤ ,0625 ; "" ;
fraction ≤ ,1875 ; "1/8" ;
fraction ≤ ,3125 ; "1/4" ;
fraction ≤ ,4375 ; "3/8"  ;
fraction ≤ ,5625 ; "1/2" ;
fraction ≤ ,6875 ;  "5/8" ;
fraction ≤ ,8125 ; "3/4" ;
fraction ≤ ,9375 ; "7/8" ;
"8/8"
)
];
whole + (precision = "8/8")  &  Case ( precision ≠ "8/8" ; " " & precision )
)
```

or, result is number

```Let
( [
inchfull = Round (centi * ,393700787;4) ;
whole = Truncate ( inchfull ; 0 ) ;
fraction = inchfull - whole ;
precision =
Case
(
fraction ≤ ,0625 ; 0 ;
fraction ≤ ,1875 ; ,125 ;
fraction ≤ ,3125 ; ,25 ;
fraction ≤ ,4375 ; ,375 ;
fraction ≤ ,5625 ; ,5 ;
fraction ≤ ,6875 ; ,625 ;
fraction ≤ ,8125 ; ,75 ;
fraction ≤ ,9375 ; ,875 ;
1
)
];
whole + precision
)
```

please note that these calcs only give an estimate of the original SI centimeter value.

##### Share on other sites  kjoe,

You are brilliant and fast!

It works like a dream (I used the result is a number version). Beautiful!

Thank you so much Julia

• ### Images

• By Soliant Consulting,
• By Soliant Consulting,
• By Soliant Consulting,
• ### Forum Statistics

• Total Topics
33.7k
• Total Posts
141.6k
×
×
• Create New...