Re: scientific notation with significant figures

2013-07-15 Thread Roger Austin

 Keith McGee  wrote: 
> 
> >http://cflib.org/udf/scientificFormat
> >
> >
> >On Fri, Jul 12, 2013 at 8:41 AM, Keith McGee wrote:
> >
> >>
> 
> This didn't help, Thanks for the link though.

The last time I had to deal with significant figures was in Pascal or Fortran. 
My 
approach was to write a procedure that would take the real value and the 
number of significant figures. I would multiply by 10*sigfigs, truncate, then 
create the string representing the decimal value. I would test the number of 
values from the decimal point and pad with 0s if needed.
All I needed was the resulting text sort of like a Hollerith in Fortran. It has 
been 
25+ years ago, but I think that's what I did. Note that real numbers are stored 
in logarithmic format so you need to pass strings after you convert.

It gets complicated if you need to have the real value back so you can do math. 
I remember having code that would do basic math functions (+-*/) on two string 
values of numbers and calculate the proper number of sig figs when the two 
numbers 
had varying significant figures (i.e., "1.89325 * 10.1". That was freaky.

There could be a Java package somewhere you could use, but I don't know of one.
--
LinkedIn: http://www.linkedin.com/pub/roger-austin/8/a4/60
Twitter:  http://twitter.com/RogerTheGeek
Blog: http://RogerTheGeek.wordpress.com/

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356190
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: scientific notation with significant figures

2013-07-15 Thread Keith McGee

>http://cflib.org/udf/scientificFormat
>
>
>On Fri, Jul 12, 2013 at 8:41 AM, Keith McGee wrote:
>
>>

This didn't help, Thanks for the link though.


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356188
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


scientific notation with significant figures

2013-07-12 Thread Keith McGee



 function SFFormat(fltNumber,intSF) {
  intExponent=int(log10(abs(fltNumber)))-intSF+1;
  return round(fltNumber/10^intExponent) * 10^intExponent;
}











#num3#

With this code the answer comes out 200 x 10^4 I need 2.00 x 10^4

I cant get the decimal to appear correctly. Any thoughts?

Thanks
Keith

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356174
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: scientific notation with significant figures

2013-07-12 Thread John M Bliss

http://cflib.org/udf/scientificFormat


On Fri, Jul 12, 2013 at 8:41 AM, Keith McGee wrote:

>
> 
> 
>  function SFFormat(fltNumber,intSF) {
>   intExponent=int(log10(abs(fltNumber)))-intSF+1;
>   return round(fltNumber/10^intExponent) * 10^intExponent;
> }
> 
>
> 
> 
>
>  "_+___"))#">
>
> 
>
> 
>
> #num3#
>
> With this code the answer comes out 200 x 10^4 I need 2.00 x 10^4
>
> I cant get the decimal to appear correctly. Any thoughts?
>
> Thanks
> Keith
>
> 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356173
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


scientific notation with significant figures

2013-07-12 Thread Keith McGee



 function SFFormat(fltNumber,intSF) {
  intExponent=int(log10(abs(fltNumber)))-intSF+1;
  return round(fltNumber/10^intExponent) * 10^intExponent;
}











#num3#

With this code the answer comes out 200 x 10^4 I need 2.00 x 10^4

I cant get the decimal to appear correctly. Any thoughts?

Thanks
Keith

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356172
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm