|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: st: RE: Keeping trailing zeros when formatting a decimal
<031173627889364697C50B3B266CBB8A051E78EC@GEOGMAIL.geog.ad.dur.ac.uk>
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
=20
log10 wasn't available back then. I am not sure floor( ) was available=2C e=
ither.
=20
At least that's my excuse.
In a way my codes are utterly basic=2C doing it from scratch from the princ=
iples=20
of high school mathematics.
=20
No doubt the codes can be shortened.
There is something about the negative number rounding in the wrong directio=
n=20
but I don't recall offhand.
Incidently=2C this is an example that doesn't work without a further adjust=
ment.
=20
. di round(10 * 10^mod(log10(0.0001)=2C 5))
100
=20
Roy
=20
=20
> This generated a lively thread. (Oddly enough=2C although I still remembe=
r
> teachers stressing the idea of sig.fig. -- as it was called where I grew
> up -- in practice I always want to program display with either Stata's
> defaults or a fixed number of decimal places.)=20
>=20
> My one contribution is slightly oblique. If existing formats don't suit=
=2C
> it seems a better strategy to drill down and try first principles.=20
>=20
> 1. Significant figures can be got from the fractional part of the base
> 10 logarithm of whatever it is.=20
>=20
> . di round(10 * 10^mod(log10(.123456789)=2C 1))
> 12
>=20
> . di round(10 * 10^mod(log10(123456789)=2C 1))
> 12
>=20
> -- with different prefactors as desired.=20
>=20
> 2. Multiplying powers can be got from the integer part of same.=20
>=20
> . di floor(log10(123456789))
> 8
>=20
> . di floor(log10(.123456789))
> -1
>=20
> 3. Logically it seems that's all the information you need to work out
> leading and trailing zeros=2C except that if there's a negative sign you
> have to strip it off first and put it back again.=20
>=20
> I haven't tried to understand Roy Wada's program=2C which at heart should
> be equivalent to this. No doubt the help file will document that it also
> deals with complications that I have missed.=20
>=20
> Nick=20
> [email protected] =0A=
_________________________________________________________________=0A=
Microsoft brings you a new way to search the web. Try Bing=99 now=0A=
http://www.bing.com?form=3DMFEHPG&publ=3DWLHMTAG&crea=3DTEXT_MFEHPG_Core_ta=
gline_try bing_1x1=
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/