Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,870 questions

51,793 answers

573 users

How to use nextUp() to get floating-point value adjacent to the argument in the direction of positive infinity in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {
 
    public static void main(String[] args) {
        
        System.out.println("nextUp(0.0, 1.0) = " + Math.nextUp(0.0));
        System.out.println("nextUp(0.0, -1.0) = " + Math.nextUp(-1.0));
        System.out.println("nextUp(0.1, 0) = " + Math.nextUp(0.1));
        System.out.println("nextUp(3.11, 1) = " + Math.nextUp(1.0));
        System.out.println("nextUp(3.11, -1) = " + Math.nextUp(3.11));
        System.out.println("nextUp(3.11, 2) = " + Math.nextUp(2));
        System.out.println("nextUp(3.11, 3) = " + Math.nextUp(3));
        System.out.println("nextUp(3.11, 4.10) = " + Math.nextUp(4.10));
        System.out.println("nextUp(3.11, 5.10) = " + Math.nextUp(5.10));
    }
}
 
/*
run:

nextUp(0.0, 1.0) = 4.9E-324
nextUp(0.0, -1.0) = -0.9999999999999999
nextUp(0.1, 0) = 0.10000000000000002
nextUp(3.11, 1) = 1.0000000000000002
nextUp(3.11, -1) = 3.1100000000000003
nextUp(3.11, 2) = 2.0000002
nextUp(3.11, 3) = 3.0000002
nextUp(3.11, 4.10) = 4.1000000000000005
nextUp(3.11, 5.10) = 5.1000000000000005
 
*/

 



answered Sep 10, 2016 by avibootz
...