1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 18 public class Main { 19 assertFloatEquals(float expected, float result)20 public static void assertFloatEquals(float expected, float result) { 21 if (expected != result) { 22 throw new Error("Expected: " + expected + ", found: " + result); 23 } 24 } 25 loop()26 public int loop() { 27 float used1 = 1; 28 float used2 = 2; 29 float used3 = 3; 30 float used4 = 4; 31 float invar1 = 15; 32 float invar2 = 25; 33 float invar3 = 35; 34 float invar4 = 45; 35 float i = 0.5f; 36 37 do { 38 used1 = invar1 + invar2; 39 used2 = invar2 - invar3; 40 used3 = invar3 * invar4; 41 used4 = invar1 * invar2 - invar3 + invar4; 42 i += 0.5f; 43 } while (i < 5000.25f); 44 assertFloatEquals(Float.floatToIntBits(used1 + used2 + used3 + used4), 1157152768); 45 return Float.floatToIntBits(used1 + used2 + used3 + used4); 46 } 47 main(String[] args)48 public static void main(String[] args) { 49 int res = new Main().loop(); 50 } 51 } 52