Hello, this is about a conversion from int to byte and int to double. Why does iftest1a work and iftest1b doesn’t? What must be done to get iftest1b to work properly?
Compiles and runs with result: „i < a“ [ edited to preserve formatting using the [code] and [/code] UBB tags -ds ] [ July 24, 2002: Message edited by: Dirk Schreckmann ]
Joined: Jul 18, 2002
Primitives can be automatically converted if the new primitive is 'wider'. So the following is possible: int (32 bits) -> double (64 bits) However, you cannot automatically convert to a narrower primitive. This is not possible: int (32 bits) -> byte (8 bits) To do this, you must use an explicit cast expression: int i = 3; byte b = (byte)i; Cheers, Neil [ July 24, 2002: Message edited by: Neil Laurance ]