Regarding wrong ceil and floor values

Why there is wrong output of ceil and floor values in this code :

enter code here
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
float y = 99999980;
float z =-99999980;
ll x = ceil(y);
ll q = floor(z);
cout<<x<<endl<<q<<endl;
}

output is
99999984
-99999984

can any one explain me why such thing is happening ?

yes that should be the reason . even when i am printing y and z

it is giving

1e+08
&
-1e+08

Thanks for the explanation !

Good answer. Nice!!

1 Like

@vijju123 seen u after 3 days !!

Hmm. I can think of 3 instances-

  1. When you become a 7 star
  2. When you get a good placement and job from college and your parents start looking for your *dramatic cough*
  3. When you decide to give us all a treat :3 :stuck_out_tongue: :o
1 Like

Third one is the one i expect to be the sooner one of all three. @vijju123 :wink:

btw, Nice answer @aryanc403

1 Like

Thank you @vijju123 @taran_1407 @worldunique
This was my first answer on codechef forum and got accepted.
Thank you.

2 Likes