How do I make conditional statement in the input line to change color based on the cell value is a power or two or not?
For example, if the cell value on A3 is a power of two i want it to return bold or a colorized value, if it is not a power of two then i want it to leave it as it is.
The following formula formats the cell to Heading 1
(bold) for powers of 2.
=3+5+STYLE(IF(MOD(LOG(CURRENT();2);1)=0;"Heading 1";"Default"))
Explanation:
= 3 + 5
is an example cell value that results in power of two.+ STYLE
applies a style. STYLE
returns zero, so adding zero will not change a numeric result.LOG(x,2)
tests whether the value is a power of 2. If it is, then MOD(x,1)
should be zero.CURRENT()
is the current value of the cell. Be careful not to use this more than once in a formula.Documentation: STYLE