Re: Significant Figures

From: Alan Johnson <alan.johnson_at_gel.com>
Date: 1996/07/05
Message-ID: <31DCACF0.30BF_at_gel.com>#1/1


Steve Cosner wrote:
>
> In article <31D9FA54.B3_at_csus.edu>, Mitchell Ryan <ryanmr_at_csus.edu> wrote:
> >Mitchell Ryan wrote:
> >>
> >> Does any know of an Oracle function that handles significant figures?
> >> Or does anyone know of an function that someone has written that I
> >> can download that does this?
 

> >What I mean by this is that I am looking for a function that I can
> >specify I want, say, two significant figures, and Oracle function will
> >evaluate the number in the column and return, two significant figures.
> >By example: if I'm given a number like 12.043, and I specify 2
> >significant figures than I want returned 12.
> >
> >If I wanted 3 significant figures the number returned would be 12.04
> >(the zero is the place holder in this case).
>
> You will have to write something yourself. The only problem I see is
> your interpretation of the zero in your 12.04 example. 12.04 looks
> like 4 significant figures to me. Three significant figures would be
> 12.0.
>

Indeed you will have to write something yourself, and indeed, the value you specify has 4 sigfigs not 3. I've written this very thing, but, unfortunately, can't give it away. I would suggest that you use the fact that significance is explicitly defined for all numbers expressed in scientific notation. For example, 12.04 to 4 sigfigs would be:

 1.204E01

and the same number expressed to 3 would be

 1.20E01

so, take your number, convert to sci notation, with an expression like charval := to_char(yourNumber,yourSigFigs expressed as 9.99EEEE), and then convert back, using to number. Its not quite that easy, but not too much harder either. Sorry I can't be more explicit (a la give you code!)

HTH Alan


---
Alan Johnson                                              MIS Director
email: alan.johnson_at_gel.com                       General Engineering 
Labs
v: (803) 556-8171 f: (803) 766-1178     2040 Savage Road, Charleston,SC 
29414
Received on Fri Jul 05 1996 - 00:00:00 CEST

Original text of this message