bit manipulation - How can I efficiently zero out the last 32 bits of a double in java? -
how can 0 out last 32 bits of double, in java, efficiently possible?
try this.
private static final long zero_out_last_32_bits = 0xffffffff00000000l; public static void main(string[] args) { double number = 2.5; long numberbits = double.doubletolongbits(number); double result = double.longbitstodouble(numberbits & zero_out_last_32_bits); }
it zeroes out last 32 bits of binary representation of double using binary and operation.
however, make sure know , why doing - @ least expect explaining comment next code this.
Comments
Post a Comment