Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Rounding numbers to significant digits
Thanks for the wonderful answer.
Here is another solution anonymous crontributed by email. Not eloquent but it certainly works for numbers > 0.
power(10,ceil(log(10,result_value)) +
log(10,round(power(10,(log(10,result_value) -
ceil(log(10,result_value)))),3)))
result_value is the number of interest and 3 is the number of significant digits, you could replace 3 with whatever sig dig's you wanted.
Rilecode
"justme" <paulq_at_rogers.com> wrote in message news:<tDZx9.201549$%h2.127343_at_news02.bloor.is.net.cable.rogers.com>...
> write a function
>
> "rilecode" <rilecode_at_chemist.com> wrote in message
> news:bd18bdcd.0211051000.5b4a2d1c_at_posting.google.com...
> > I am trying to round numbers to 3 significant digits, no matter where
> > the decimal is placed. I can bin the numbers into groups and use a
> > separate round function for each bin, however, this method seems ugly.
> > Oracle stores the data in scientific notation, does Oracle have a way
> > to round on scientific notation. Here is an example data set: The
> > left side is what is in the database, the right side is what I want to
> > have in the database.
> >
> >
> > 0.00057593657984145 0.000576
> > 0.0160203850509626 0.0160
> > 0.00782930917327293 0.00783
> > 10.855832389580974 10.9
> > 251.497046432616080 251
> > 0.0509346953666545 0.0510
> > 1.339710636373912 1.34
> > 20.203388719339889 20.2
> > 0.00675144116649712 0.00675
> > 0.0418077518192264 0.0418
> > 0.00000303206625813864 0.00000303
> > 2.729014132516280 2.73
> > 0.851564387096774 0.852
> >
> >
> > I appreciate all solutions.
> >
> > Rilecode
Received on Wed Nov 06 2002 - 17:57:39 CST
![]() |
![]() |