## #1156 float(ceiling(...)) sometimes returns float, sometimes int

closed
nobody
5
2008-02-09
2007-03-30
No

float(ceiling(log(9)/log(2))) => 3.0 (a float)
float(ceiling(log(8)/log(2))) => 3 (an integer)

This is because
ceiling(log(9)/log(2))=4
but
ceiling(log(8)/log(2)) => ceiling(log(8)/log(2))
and only simplifies to a number when the argument is evaluated as a float.

float(ceiling(log(2^80)/log(2))) => 80 (an integer)
float(ceiling(log(2^80-1)/log(2))) => 80.0 (a float)

Shouldn't float(...) always be returning a float if it's returning a number? I think the problem is that it assumes that if f(x) simplifies to a number, and x is a float, then f(x) is a float.

I think it makes sense for ceiling(2.3) => 3 (not 3.0), so the problem seems to be in float, not in simp-ceiling.

You could argue that ceiling should do a better job in the first place, but that's an orthogonal issue, and in any case it will never handle all possible cases.

## Discussion

• Dan Gildea - 2008-02-09

Logged In: YES
user_id=1797506
Originator: NO

Seems ok in current cvs.

(%i1) float(ceiling(log(8)/log(2))) ;
(%o1) 3.0
(%i2) float(ceiling(log(2^80)/log(2))) ;
(%o2) 80.0
(

• Dan Gildea - 2008-02-09
• status: open --> closed