java - a long bigger than Long.MAX_VALUE -
how can long number bigger long.max_value?
i want method return true:
public static isbiggerthanmaxlong(long l){ return l>long.max_value; }
um, method can't return true
. that's point of long.max_value
. really confusing if name were... false. should called long.some_fairly_large_value
, have literally 0 reasonable uses. use android's isuseragoat
, or may roll own function returns false
.
note long
in memory takes fixed number of bytes. from oracle:
long: long data type 64-bit signed two's complement integer. has minimum value of -9,223,372,036,854,775,808 , maximum value of 9,223,372,036,854,775,807 (inclusive). use data type when need range of values wider provided int.
as may know basic computer science or discrete math, there 2^64 possible values long, since 64 bits. , know discrete math or number theory or common sense, if there's finitely many possibilities, 1 of them has largest. long.max_value
. asking tantamount "is there integer that's >0 , < 1?" mathematically nonsensical.
if need real use biginteger
class.
Comments
Post a Comment