Révision 268
pobysoPythonSage/src/sageSLZ/sageNumericalOperations.sage (revision 268) | ||
---|---|---|
3 | 3 |
def sno_abs_is_power_of_two(number): |
4 | 4 |
""" |
5 | 5 |
Check if the absolute value of a number is power of 2. |
6 |
The built-in is_power_of_two, works with many kinds of numbers but
|
|
6 |
As of Sage 7.1, the built-in is_power_of_two, only works with integer and
|
|
7 | 7 |
returns false for negative ones. |
8 | 8 |
""" |
9 |
return is_power_of_two(abs(number)) |
|
9 |
#return is_power_of_two(abs(number)) |
|
10 |
log2number = log(abs(number))/log(2) |
|
11 |
return log2number.n() == long(log2number.n()) |
|
10 | 12 |
# End sno_abs_is_power_of_two(number): |
11 | 13 |
# |
12 | 14 |
def sno_float_to_rat_pow_of_two_denom(number): |
Formats disponibles : Unified diff