Re: Need unrounded precision
| From: | Andre Dubuc | Date: | Mon, 12 Oct 2009 01:16:02 +0000 |
| Subject: | Re: Need unrounded precision | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-298847@lists.php.net to get a copy of this message | ||
Yup! I had noticed that I had forgot to reset to today's date after working on
the code, just after I sent the messages.
Thanks.
Andre
On October 11, 2009 09:14:56 pm Jim Lucas wrote:
> Andre Dubuc wrote:
> > Hi,
> >
> > I need to extract the first digit after the decimal point from a number
> > such as 28.56018, which should be '5'.
> >
> > I've tried a few methods to accomplish this. If I use 'ini_set' I would
> > need to know the number of digits before the decimal (which,
> > unfortunately, I would not have access to).
> >
> > Then I've tried:
> >
> > <?php
> >
> > $elapsed = 28.56018;
> >
> > $digit = round($elapsed, 1); // rounds result is '6'
> > $digit = number_format($elapsed, 1); // still rounds result to '6'
> >
> > ?>
> >
> > What I need is only the first digit after the decimal -- all the rest
> > could be 'chopped' or discarded but without rounding the first digit
> > after the decimal point.
> >
> > Is there any way of doing this?
> >
> > I'm stumped.
> >
> > Tia,
> > Andre
>
> FYI: did you know that your computer thinks it is in the future?
>
> You need to check your date settings...
>
> --
> Jim Lucas
>
> "Some men are born to greatness, some achieve greatness,
> and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
> by William Shakespeare