I wrote a program in java
and php
. In which a loop
runs 64
times. And keep adding n to n
:
Java Code:
public static void main(String[] args) {
double n = 1;
double p = 1;
for(int i = 1;i <= 64;i++){
n = n + n;
p = p + n;
}
System.out.println(p);
}
PHP code:
<?php
$n = 1;
$p = 0;
for($i = 1;$i <= 64;$i++){
$n = $n + $n;
$p = $p + $n;
}
echo($p);
?>
And the output of both of these is:
3.6893488147419E+19
Now I want to know is it possible to convert this big float to int? if yes, Then how. In both languages.