/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	static void check(double x) {
		double a, b;
		System.out.printf("%9s %9s %23s %5s%n", x, a = x - Math.ulp(x), b = Math.nextAfter(x, Double.NEGATIVE_INFINITY), 
		a == b);
		System.out.printf("%9s %9s %23s %5s%n", x, a = x + Math.ulp(x), b = Math.nextAfter(x, Double.POSITIVE_INFINITY), 
		a == b);
		System.out.println();
		
	}
	public static void main (String[] args) throws java.lang.Exception
	{
		check(0);
		check(Double.POSITIVE_INFINITY);
		check(Double.NEGATIVE_INFINITY);
		check(Double.NaN);
	}
}