Forums Register Login

implicit casting with retun types

+Pie Number of slices to send: Send
This code works fine


But this gives an error: Possible loss of precision


float is smaller than long (in number of bits) so is byte.
Why can we return one and not another?
+Pie Number of slices to send: Send
In the second example, you're actually trying to return a long from a method that can only return a byte!

In addition, when it comes to narrowing and widening conversions, I'd suggest reading this.
+Pie Number of slices to send: Send
 

Originally posted by Corey McGlone:
In the second example, you're actually trying to return a long from a method that can only return a byte!

In addition, when it comes to narrowing and widening conversions, I'd suggest reading this.



But even in the first example i am returning a long when it can return a float.
float is 32 bits and long is 64 bits. Then why does that compile.
+Pie Number of slices to send: Send
 

In addition, when it comes to narrowing and widening conversions, I'd suggest reading this.



Thank You so much Corey.
That was too good.
You are great
This guy is skipping without a rope. At least, that's what this tiny ad said:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 640 times.
Similar Threads
method overriding
Which eat method and why ??
Why this Output?
Reference Types and Instance Types
Question from New Boone
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 01:23:47.