Skip to content

Commit

Permalink
Fixed edge cases of nearest_po2 function
Browse files Browse the repository at this point in the history
  • Loading branch information
MewPurPur committed Apr 12, 2023
1 parent 10d22a4 commit bdbc619
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions doc/classes/@GlobalScope.xml
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,7 @@
<return type="int" />
<param index="0" name="value" type="int" />
<description>
Returns the nearest equal or larger power of 2 for the integer [param value].
In other words, returns the smallest value [code]a[/code] where [code]a = pow(2, n)[/code] such that [code]value &lt;= a[/code] for some non-negative integer [code]n[/code].
Returns the smallest integer power of 2 that is greater than or equal to [param value].
[codeblock]
nearest_po2(3) # Returns 4
nearest_po2(4) # Returns 4
Expand All @@ -702,7 +701,7 @@
nearest_po2(0) # Returns 0 (this may not be expected)
nearest_po2(-1) # Returns 0 (this may not be expected)
[/codeblock]
[b]Warning:[/b] Due to the way it is implemented, this function returns [code]0[/code] rather than [code]1[/code] for negative values of [param value] (in reality, 1 is the smallest integer power of 2).
[b]Warning:[/b] Due to its implementation, this method returns [code]0[/code] rather than [code]1[/code] for negative values of [param value]. It also has no effect if [param value] is at the negative integer limit.
</description>
</method>
<method name="pingpong">
Expand Down

0 comments on commit bdbc619

Please sign in to comment.