Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Convert decimal to fraction
Message
De
10/02/2003 19:14:34
Fabian Belo
Independent Developer
Argentine
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00751688
Message ID:
00751725
Vues:
86
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform