Userid handling

From Bebot Wiki 2
Revision as of 22:37, 16 September 2020 by B3b0tUzR (talk | contribs) (Created page with 'In previous series of BeBot UserID's have been treated as integer values. This has been due to the fact that unlike most other operations in PHP, unpack() does NOT automatically …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

In previous series of BeBot UserID's have been treated as integer values. This has been due to the fact that unlike most other operations in PHP, unpack() does NOT automatically convert numeric values greater than a 32bit integer can handle to a float. As such BeBot allowed the integer to overflow to become a negative signed integer.

As of BeBot 0.7.0 this is no longer true. We now handle high UserID's as floats, and as such this means special care have to be taken whenever comparing UserID's.

Do NOT compare UserID's the way you would a normal integer, ie if ($userid == $userid2) Instead use the bc_cmp function, ie if (bccomp($userid, $userid2) == 0)

bccomp return values are Returns 0 if the two operands are equal, 1 if the left_operand is larger than the right_operand , -1 otherwise.