Project

General

Profile

Slug #1680

FloorLog2 or SizeInBase?

Added by John Abbott about 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Tidying
Target version:
Start date:
21 Apr 2022
Due date:
% Done:

100%

Estimated time:
1.66 h
Spent time:

Description

In several places FloorLog2 is used to obtain a quick estimate of the
size of an integer; however, SizeInBase is noticeably faster (and just
as accurate, if the base is 2).

Check through the code, and replace FloorLog2 by SizeInBase where appropriate.


Related issues

Related to CoCoALib - Design #1693: SizeInBase: obsoleteClosed2022-08-08

History

#1 Updated by John Abbott about 2 years ago

I had completely forgotten that we had created SizeInBase.
FloorLog2 is fairly quick, but SizeInBase is instant.

I do not really expect changing the calls to make a great speed
difference, but it is worth changing just for "cleanliness"
(and to remind me that SizeInBase is the quick size estimate fn).

#2 Updated by John Abbott almost 2 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

Would it not be better to use the name BitSize rather than require that the user call SizeInBase(N,2)?
Would we even need to make SizeInBase public?

#3 Updated by John Abbott almost 2 years ago

Anna says that I should have impl'd FloorLog2 so that it calls SizeInBase directly.
Ooops. Why did I not think of that?

#4 Updated by John Abbott almost 2 years ago

  • Status changed from In Progress to Feedback
  • % Done changed from 10 to 90

Changed impl of FloorLog2 as described above... why was it not already like that? No idea!
All tests pass.

#5 Updated by John Abbott almost 2 years ago

SizeInBase is called only rarely; I have replaced one by a call to FloorLog2 because I think it makes the code clearer.

I shall remove the default value for arg 2 in SizeInBase since it makes no sense (to me now).

#6 Updated by John Abbott over 1 year ago

#7 Updated by John Abbott over 1 year ago

  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100
  • Estimated time set to 1.66 h

After discussion with Anna we have decided that SizeInBase is obsolete; so the original question here is no longer relevant.

FloorLog2 has been made faster (both for BigInt and for machine ints).

Also available in: Atom PDF