Skip to main content

Just want to convert from string containing fractional numbers (e.g.,

4 1/2

 

2 7/8

...

to decimal doubles

4.5

2.875

...

Anyway to not use multiple transformers for this? ( I know I can separate the fraction from the whole number, then value map the fractional segment to decimal segments, and then patch the number back together via concatenation...). However, I thought I'd check to see if I'm missing something less bulky.

Many thanks,

 

Pete

Here's a template workspace using a StringSearcher and an ExpressionEvaluator to convert fractions to decimals: fractions.fmwt

Example: "12 3/4" is converted to 12.75

You'll probably have to implement some checks to cover numbers without the trailing fraction and perhaps some other edge cases, but it should be fairly easy.


Here's a template workspace using a StringSearcher and an ExpressionEvaluator to convert fractions to decimals: fractions.fmwt

Example: "12 3/4" is converted to 12.75

You'll probably have to implement some checks to cover numbers without the trailing fraction and perhaps some other edge cases, but it should be fairly easy.

Cool thanks! Very helpful.

 

I believe you meant "12 3/5 is converted to 12.6". Ha ha.

 

 


Here's a template workspace using a StringSearcher and an ExpressionEvaluator to convert fractions to decimals: fractions.fmwt

Example: "12 3/4" is converted to 12.75

You'll probably have to implement some checks to cover numbers without the trailing fraction and perhaps some other edge cases, but it should be fairly easy.

Just tried it. Very nice. Thanks again!

 

 


Cool thanks! Very helpful.

 

I believe you meant "12 3/5 is converted to 12.6". Ha ha.

 

 

Whoops, nasty typo, good catch. Fixed 🙂

Reply