Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert decimal to fraction
Message
From
10/02/2003 19:14:34
Fabian Belo
Independent Developer
Argentina
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00751688
Message ID:
00751725
Views:
82
This message has been marked as the solution to the initial question of the thread.
I've made this function few weeks ago:
FUNCTION _DecToFraction(nDec1)
*-----------------------------------
* Transforma de Decimal a Fraccion
* Uso:  _DecToFraction(nDec1)
* Devuelve:  Caracter
*-----------------------------------
	LOCAL cRes, nCon
	nCon = 0
	cRes = "No Fraction"
	DO WHILE nCon<1000000
		nCon = nCon+1
		DO CASE
			CASE MOD(nCon,nDec1)=0
				cRes=ALLTRIM(STR(nCon))+"/"+ALLTRIM(STR(nCon/nDec1))
				EXIT
		ENDCASE
	ENDDO
	RETURN cRes
ENDFUNC
>I need to convert a decimal to a fraction... anyone have/know of a function for this?
>
>
>.5 --> 1/2
>
>.1875 --> 3/16
>
>TIA
"Since I've read that alcohol is bad... I quit reading."
Me


http://www.fabianbelo.com.ar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform