SNIPPET: java.lang.Float
SNIPPET: java.lang.Float
We’ll play a little with floats here. Remember, you’ll love the language by getting worn out using it. One more exercise is not too much.
package api_package;
public class Lagosian {
static int ngozi_age = 25;
public static void main(String[] args) {
//note that this is in accord with IEEE 754
//floating point single-format bit layout.
System.out.print("Ngozi's age in floating point is: ");
System.out.println(Float.intBitsToFloat(ngozi_age));
//just to check that we are consistent
//note repetition of above methods
System.out.print("Just to be sure we're still on course:
");
System.out.println(Float.floatToRawIntBits(Float.intBitsToF
loat(ngozi_age)));
//try other exercises. you have the fundamentals to
//work with java for the maths inclined
}
}

No comments:
Post a Comment