Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert decimal to fraction
Message
From
10/02/2003 19:45:14
 
 
To
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:
00751730
Views:
35
The problem with this is that in most US applications this will have to restricted to ^2
like 1/2,1/4,1/16,1/32....

Peter


>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
Peter Cortiel
Previous
Reply
Map
View

Click here to load this message in the networking platform