Thanks I will give it a try. Dan
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Dennis McGrath Sent: Thursday, August 08, 2002 6:19 PM To: [EMAIL PROTECTED] Subject: RE: Converting Decimal to fractions > I have a field that I use to input as decimal (1.0625). I need to convert > that to a fraction. > > Does anybody have a routine to convert decimal to fraction?? > > Thanks > > Dan Try this. It should give you an answer accurate to the nearest 64th. set var vNumber REAL = 1.0625 -- for testing SET VAR vResult TEXT = (CTXT(INT(.vNumber))) SET VAR vDivisor INTEGER = 64 SET VAR vDividend INTEGER = (BRND(((MOD(.vNumber,1)) * .vDivisor),15,1)) IF vDividend > 0 THEN WHILE (MOD(.vDividend,2)) = 0 THEN SET VAR vDividend = (.vDividend / 2) SET VAR vDivisor = (.vDivisor / 2) ENDWHILE vResult = (.vResult + '-' + CTXT(.vDividend) + '/' + CTXT(.vDivisor)) ENDIF -- Dennis McGrath mailto:[EMAIL PROTECTED] -- Productivity Tools for R:Base Programmers http://www.enteract.com/~mcgrath/dennis -- Full time consultant with: SQL Resources Group Steve Hartmann Oak Park, IL mailto:[EMAIL PROTECTED] ================================================ TO SEE MESSAGE POSTING GUIDELINES: Send a plain text email to [EMAIL PROTECTED] In the message body, put just two words: INTRO rbase-l ================================================ TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED] In the message body, put just two words: UNSUBSCRIBE rbase-l ================================================ TO SEARCH ARCHIVES: http://www.mail-archive.com/rbase-l%40sonetmail.com/ ================================================ TO SEE MESSAGE POSTING GUIDELINES: Send a plain text email to [EMAIL PROTECTED] In the message body, put just two words: INTRO rbase-l ================================================ TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED] In the message body, put just two words: UNSUBSCRIBE rbase-l ================================================ TO SEARCH ARCHIVES: http://www.mail-archive.com/rbase-l%40sonetmail.com/
