---
title: 'Math.nextUp(…) und nextDown(…)'
url: 'https://www.tutego.de/blog/javainsel/2014/01/math-nextup-und-nextdown'
markdown: 'https://www.tutego.de/blog/javainsel/2014/01/math-nextup-und-nextdown.md'
date: '2014-01-03'
description: 'Was kommt nach und vor 1: System.out.printf( "%.16f%n", Math.nextUp( 1 ) ); System.out.printf( "%.16f%n", Math.nextDown( 1 ) ); System.out.printf( "%.16f%n", Math.nextAfter( 1, Double.POSITIVE_INFINITY ) ); System.out.printf( "%.16f%n", Math.nextAfter( 1, Double.NEGATIVE_INFINITY ) ); Die Ausgabe i…'
taxonomy:
  category:
    - Insel
    - 'Java 8'
---

# Math.nextUp(…) und nextDown(…)

![Illustration einer tropischen Insel mit Palmen und einem hohen Berg](https://www.tutego.de/blog/javainsel/user/themes/tutego/images/insel-cover.jpg)# Java Blog für Programmierer

[Java Blog für Programmierer](https://www.tutego.de/blog/javainsel/)

## Math.nextUp(…) und nextDown(…)

03.01.2014 · [Christian Ullenboom](https://www.tutego.de/blog/javainsel/author/admin/)

Was kommt nach und vor 1:

```java
System.out.printf( "%.16f%n", Math.nextUp( 1 ) );
System.out.printf( "%.16f%n", Math.nextDown( 1 ) );
System.out.printf( "%.16f%n", Math.nextAfter( 1, Double.POSITIVE_INFINITY ) );
System.out.printf( "%.16f%n", Math.nextAfter( 1, Double.NEGATIVE_INFINITY ) );
```

Die Ausgabe ist:

1,000000119209289

0,9999999403953552

1,0000001192092896

0,9999999403953552

next**Up**(d) ist eine Abkürzung für `nextAfter`(d, Double.**POSITIVE\_INFINITY**) und next**Down**(d) eine Abkürzung für `nextAfter`(d, Double.**NEGATIVE\_INFINITY**). Ist das zweite Argument von `Math.nextAfter(…)` größer als das erste, dann wird die nächstgrößere Zahl zurückgegeben, ist sie kleiner, dann die nächstkleinere Zahl. Bei Gleichheit kommt die gleiche Zahl zurück.

Kategorien: [Insel](https://www.tutego.de/blog/javainsel/category/insel/), [Java 8](https://www.tutego.de/blog/javainsel/category/java-8/)

[← Alle Beiträge](https://www.tutego.de/blog/javainsel/)

---

## Navigation

- Previous: [Division mit Rundung Richtung negativ unendlich, alternativer Restwert](https://www.tutego.de/blog/javainsel/2014/01/division-mit-rundung-richtung-negativ-unendlich-alternativer-restwert.md)
- Next: [Überlauf in Java 8 erkennen](https://www.tutego.de/blog/javainsel/2014/01/berlauf-in-java-8-erkennen.md)
