These are two type-casting ways for all datatypes , right?
int(variable)
(int) variable
These are two type-casting ways for all datatypes , right?
int(variable)
(int) variable
why there is typecasting used (long long) in the isPrime function (inside loop)
https://drive.google.com/file/d/1FBd_EoCIb5hpW7wwBPb-sv_LXYF4_F5c/view?usp=sharing
https://drive.google.com/file/d/118paW9_HIiIdRc_hIYusMFawkiC0mkYb/view?usp=sharing
https://drive.google.com/file/d/1FBd_EoCIb5hpW7wwBPb-sv_LXYF4_F5c/view?usp=sharing
that is done to avoid overflow.
the product may exceed the integer range hence we need to typecast to long long
@aman212yadav
so can i say, if I have a variable -> int var = 10^6;
and I want to perform - > i * i > num ,
then I should do -> i * (long long) i > num (irrespective of num’s datatype i.e int or long long)
yeah …
…
if datatype is already long long then no need to write long long exxplicitly
@aman212yadav
so if
int var=10^6; long long num= 10^13;
now I should do: i * i > num
and NOT i * (long long) i > num
right ?
what is datatype of i?
i is int then obviously u need typecasting
then what did you meant by above ??
Please can you share both examples (typecasting used or not) by altering the same code I sent
all i am saying is
if
long long x=something ;
then while computing x*x no need of time casting.
but if it is
int x=something
then while computing x*x use typecasting i.e x *(long long) x