FogBugz (Case [Issue]10435) Kernel - Fast-up asFloat

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

FogBugz (Case [Issue]10435) Kernel - Fast-up asFloat

Pharo Issue Tracker
A FogBugz case was edited by Nicolas Cellier.

Case ID:      10435
Title:        Fast-up asFloat
Status:       Work Needed
Category:     Bug
Project:      Kernel
Area:         Misc
Priority:     6 - Fix If Time
Milestone:    Pharo3.0: 30/03/2014
Assigned To:  Everyone

URL:          https://pharo.fogbugz.com/default.asp?10435

Like in Squeak, we can fast-up asFloat

In LargePositiveInteger, defer the extra bit introspection after 7 excess bits rather than a single 1.
Indeed, this will lead to at most 60 bits. the highest 52 lead to an exact Float, and the last 8 lead to a single inexact rounding error, and thus to a correct rounding.
The cases when we must check/change the LargeInteger significand for rounding is statistically reduced to 1 case out of 256 rather than 1 out of 4.

In LargeNegativeInteger apply super asFloat on self rather than self negated since it works well. This save a useless LargeInteger creation/copy.

In Fraction directly use highBitOfMagnitude (marginal cost).

Mini benchmark:

x := { 1. 3/2. 201/100. Float pi asFraction. 1<<54+1. 1<<52+1<<3. 1<<53+1. 1<<53+1<<3+1. }.
x := x , (x collect: [:e | e negated]).
[ x do: [ :e | e asFloat ] ] bench.

BEFORE: '51,700 per second.'
AFTER:  '92,300 per second.'


Vous êtes abonné(e) à ce dossier. Si vous ne souhaitez plus recevoir de notifications automatiques à l'avenir, désabonnez-vous (https://pharo.fogbugz.com/default.asp?pre=preUnsubscribe&pg=pgEditBug&command=view&ixBug=10435) de ce dossier.

_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker