Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Borland > Re: Looking for...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 3 Topic 1068 of 1118
Post > Topic >>

Re: Looking for function

by Marco van de Voort <marcov@[EMAIL PROTECTED] > Dec 17, 2007 at 08:47 AM

On 2007-12-17, Victor Fraenckel <victorf@[EMAIL PROTECTED]
> wrote:
> I would appreciate hearing from anyone who could point me to a place to 
> grab a function the takes a floating point number and returns a string 
> that represents that number as a integer (maybe) and a fraction like 
> 3.25 = 3 1/4. Like this perhaps:
> var
>    myfrac :string;
>
> myfrac = Num2Frac(num : single);
>
> My usage is for english units commonly found in carpentry like 
> sixteenths, eighths, quarters and halves.

Better use SI :-)

Anyway, multiply the fractional part with a large power of two (e.g.
1024).
The resulting number is the upper part of your fraction, and 1024 below.
Then use the normal common denomitor way to simplify it to aa sane number.

- number: 3.25 
- frac(3.25) = 0.25
- 0.25*1024=256

So  3 256/1024
 




 3 Posts in Topic:
Looking for function
Victor Fraenckel <vict  2007-12-16 21:00:23 
Re: Looking for function
Marco van de Voort <ma  2007-12-17 08:47:23 
Re: Looking for function
Victor Fraenckel <vict  2007-12-17 20:29:45 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 0:16:12 CDT 2008.