[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*To*: STERRITT%SDEVAX.decnet@GE-CRD.ARPA*Subject*: Avoiding consing when translating numbers to strings*From*: Barry Margolin <barmar@THINK.COM>*Date*: Wed, 1 Mar 89 19:41:00 EST*Cc*: slug@WARBUCKS.AI.SRI.COM*In-reply-to*: <8903012242.AA10741@Think.COM>

If you use the optional second argument to TIME you'll see that FORMAT is consing a bunch of bignums. In order to avoid using floating point arithmetic FORMAT uses things like INTEGER-DECODE-FLOAT to convert the float to a set of integers it can process. For some floats this can result in a bignum. Much of the arithmetic that then takes place to convert this to a string conses more bignums. In the more common cases, though, only fixnums are produced, so the integer arithmetic ends up being much faster than it would have been had it been done with the original floats; unfortunately, this idea loses if the integers are bignums. One thing that I noticed reduced the consing a bit (examine-float 1d-100) went from 126 to 70 words consed) was to specify the width option to ~F, e.g. ~10F. The functions to look at for most of the consing are SI:SHORT-DECIMAL-DIGITS (for ~F) and SI:FIXED-WIDTH-DECIMAL-DIGITS (for ~nF). To do much better than these, I think you'll probably have to implement stack-consed bignums in some way (probably making use of the undocumented %BIGNUM-xxx subprimitives). You could probably reduce the consing by using floating point arithmetic (it conses, but not as much), but it makes up for the reduced consing by being slower than integer arithmetic. barmar

- Prev by Date:
**Avoiding consing when translating numbers to strings** - Next by Date:
**X, atk, Interviews** - Previous by thread:
**Avoiding consing when translating numbers to strings** - Next by thread:
**Avoiding consing when translating numbers to strings** - Index(es):