Re: Repeating Decimals

From: Date: Thu, 05 Dec 2002 19:08:48 +0000
Subject: Re: Repeating Decimals
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-127188@lists.php.net to get a copy of this message
> This is another PHP mathematical question. How can I display a bar over a > number (overline) if it's a repeating decimal? When the user types in 1 by > 3, they get 0.333333333333. I want it to display as 0.3 with the 3 > overlined. How can I do this keeping in mind that not all numbers will be > repeating decimals? Well, the first problem is finding a charset or something that has a number with a line over it and how you'd create that character in HTML, unless you want to use an image or something. Next, you can treat the result as a string and look at the last X digits. If they are the same, remove them all and substitute with the number and a bar. It just comes down to string manipulation... ---John Holmes...

« previous php.general (#127188) next »