moster67 Expert Licensed User Longtime User Dec 30, 2018 #1 in B4X (not sure about B4R), B4x casts types automatically as needed. It also converts numbers to strings and vice versa automatically. This is convenient but can also be dangerous due to loss of data. Code: Private i As Int = 50000 Private s As Short = 0 s = i Log(s) '-15536 In Java, those conversions that may lose data are called narrowing and must be explicitly demanded by the programmer using a cast Code: int i = 50000; short s = 0; //s = i; //error when writing code s = (short) i; //explicit casting System.out.println(s); //-15536 Would it be possible to implement that the IDE issues a warning when narrowing takes place? Last edited: Dec 30, 2018
in B4X (not sure about B4R), B4x casts types automatically as needed. It also converts numbers to strings and vice versa automatically. This is convenient but can also be dangerous due to loss of data. Code: Private i As Int = 50000 Private s As Short = 0 s = i Log(s) '-15536 In Java, those conversions that may lose data are called narrowing and must be explicitly demanded by the programmer using a cast Code: int i = 50000; short s = 0; //s = i; //error when writing code s = (short) i; //explicit casting System.out.println(s); //-15536 Would it be possible to implement that the IDE issues a warning when narrowing takes place?