fork download
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		long l = 1;
		double d = 1.0;
		for (int i = 0; i < 63; ++i)
		{
			l *= 2;
			d *= 2.0;
 
            System.out.format("     n: %d\n", i + 1);
			System.out.format("  long: %d (+1 = %d)\n", l, l + 1);
			System.out.format("double: %.0f (+1 = %.0f)\n", d, d + 1.0);
			System.out.println();
		}
	}
}
Success #stdin #stdout 0.12s 380544KB
stdin
Standard input is empty
stdout
     n: 1
  long: 2 (+1 = 3)
double: 2 (+1 = 3)

     n: 2
  long: 4 (+1 = 5)
double: 4 (+1 = 5)

     n: 3
  long: 8 (+1 = 9)
double: 8 (+1 = 9)

     n: 4
  long: 16 (+1 = 17)
double: 16 (+1 = 17)

     n: 5
  long: 32 (+1 = 33)
double: 32 (+1 = 33)

     n: 6
  long: 64 (+1 = 65)
double: 64 (+1 = 65)

     n: 7
  long: 128 (+1 = 129)
double: 128 (+1 = 129)

     n: 8
  long: 256 (+1 = 257)
double: 256 (+1 = 257)

     n: 9
  long: 512 (+1 = 513)
double: 512 (+1 = 513)

     n: 10
  long: 1024 (+1 = 1025)
double: 1024 (+1 = 1025)

     n: 11
  long: 2048 (+1 = 2049)
double: 2048 (+1 = 2049)

     n: 12
  long: 4096 (+1 = 4097)
double: 4096 (+1 = 4097)

     n: 13
  long: 8192 (+1 = 8193)
double: 8192 (+1 = 8193)

     n: 14
  long: 16384 (+1 = 16385)
double: 16384 (+1 = 16385)

     n: 15
  long: 32768 (+1 = 32769)
double: 32768 (+1 = 32769)

     n: 16
  long: 65536 (+1 = 65537)
double: 65536 (+1 = 65537)

     n: 17
  long: 131072 (+1 = 131073)
double: 131072 (+1 = 131073)

     n: 18
  long: 262144 (+1 = 262145)
double: 262144 (+1 = 262145)

     n: 19
  long: 524288 (+1 = 524289)
double: 524288 (+1 = 524289)

     n: 20
  long: 1048576 (+1 = 1048577)
double: 1048576 (+1 = 1048577)

     n: 21
  long: 2097152 (+1 = 2097153)
double: 2097152 (+1 = 2097153)

     n: 22
  long: 4194304 (+1 = 4194305)
double: 4194304 (+1 = 4194305)

     n: 23
  long: 8388608 (+1 = 8388609)
double: 8388608 (+1 = 8388609)

     n: 24
  long: 16777216 (+1 = 16777217)
double: 16777216 (+1 = 16777217)

     n: 25
  long: 33554432 (+1 = 33554433)
double: 33554432 (+1 = 33554433)

     n: 26
  long: 67108864 (+1 = 67108865)
double: 67108864 (+1 = 67108865)

     n: 27
  long: 134217728 (+1 = 134217729)
double: 134217728 (+1 = 134217729)

     n: 28
  long: 268435456 (+1 = 268435457)
double: 268435456 (+1 = 268435457)

     n: 29
  long: 536870912 (+1 = 536870913)
double: 536870912 (+1 = 536870913)

     n: 30
  long: 1073741824 (+1 = 1073741825)
double: 1073741824 (+1 = 1073741825)

     n: 31
  long: 2147483648 (+1 = 2147483649)
double: 2147483648 (+1 = 2147483649)

     n: 32
  long: 4294967296 (+1 = 4294967297)
double: 4294967296 (+1 = 4294967297)

     n: 33
  long: 8589934592 (+1 = 8589934593)
double: 8589934592 (+1 = 8589934593)

     n: 34
  long: 17179869184 (+1 = 17179869185)
double: 17179869184 (+1 = 17179869185)

     n: 35
  long: 34359738368 (+1 = 34359738369)
double: 34359738368 (+1 = 34359738369)

     n: 36
  long: 68719476736 (+1 = 68719476737)
double: 68719476736 (+1 = 68719476737)

     n: 37
  long: 137438953472 (+1 = 137438953473)
double: 137438953472 (+1 = 137438953473)

     n: 38
  long: 274877906944 (+1 = 274877906945)
double: 274877906944 (+1 = 274877906945)

     n: 39
  long: 549755813888 (+1 = 549755813889)
double: 549755813888 (+1 = 549755813889)

     n: 40
  long: 1099511627776 (+1 = 1099511627777)
double: 1099511627776 (+1 = 1099511627777)

     n: 41
  long: 2199023255552 (+1 = 2199023255553)
double: 2199023255552 (+1 = 2199023255553)

     n: 42
  long: 4398046511104 (+1 = 4398046511105)
double: 4398046511104 (+1 = 4398046511105)

     n: 43
  long: 8796093022208 (+1 = 8796093022209)
double: 8796093022208 (+1 = 8796093022209)

     n: 44
  long: 17592186044416 (+1 = 17592186044417)
double: 17592186044416 (+1 = 17592186044417)

     n: 45
  long: 35184372088832 (+1 = 35184372088833)
double: 35184372088832 (+1 = 35184372088833)

     n: 46
  long: 70368744177664 (+1 = 70368744177665)
double: 70368744177664 (+1 = 70368744177665)

     n: 47
  long: 140737488355328 (+1 = 140737488355329)
double: 140737488355328 (+1 = 140737488355329)

     n: 48
  long: 281474976710656 (+1 = 281474976710657)
double: 281474976710656 (+1 = 281474976710657)

     n: 49
  long: 562949953421312 (+1 = 562949953421313)
double: 562949953421312 (+1 = 562949953421313)

     n: 50
  long: 1125899906842624 (+1 = 1125899906842625)
double: 1125899906842624 (+1 = 1125899906842625)

     n: 51
  long: 2251799813685248 (+1 = 2251799813685249)
double: 2251799813685248 (+1 = 2251799813685249)

     n: 52
  long: 4503599627370496 (+1 = 4503599627370497)
double: 4503599627370496 (+1 = 4503599627370497)

     n: 53
  long: 9007199254740992 (+1 = 9007199254740993)
double: 9007199254740992 (+1 = 9007199254740992)

     n: 54
  long: 18014398509481984 (+1 = 18014398509481985)
double: 18014398509481984 (+1 = 18014398509481984)

     n: 55
  long: 36028797018963968 (+1 = 36028797018963969)
double: 36028797018963968 (+1 = 36028797018963968)

     n: 56
  long: 72057594037927936 (+1 = 72057594037927937)
double: 72057594037927936 (+1 = 72057594037927936)

     n: 57
  long: 144115188075855872 (+1 = 144115188075855873)
double: 144115188075855872 (+1 = 144115188075855872)

     n: 58
  long: 288230376151711744 (+1 = 288230376151711745)
double: 288230376151711740 (+1 = 288230376151711740)

     n: 59
  long: 576460752303423488 (+1 = 576460752303423489)
double: 576460752303423490 (+1 = 576460752303423490)

     n: 60
  long: 1152921504606846976 (+1 = 1152921504606846977)
double: 1152921504606846980 (+1 = 1152921504606846980)

     n: 61
  long: 2305843009213693952 (+1 = 2305843009213693953)
double: 2305843009213694000 (+1 = 2305843009213694000)

     n: 62
  long: 4611686018427387904 (+1 = 4611686018427387905)
double: 4611686018427387900 (+1 = 4611686018427387900)

     n: 63
  long: -9223372036854775808 (+1 = -9223372036854775807)
double: 9223372036854776000 (+1 = 9223372036854776000)