Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

swift
double
nextdown
communitycreator
double value

What is the Double.nextDown property of a double value in Swift?

Theodore Kelechukwu Onyejiaku

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

The Double.nextDown property of a double value in Swift finds the greatest representable value that compares less than this value.

Syntax

Double.nextDown

Return value

This property returns the greatest representable value that compares less than the double value.

Code example

// Create some double values
let d1 = 2.3
let d2 = 0.0
let d3 = Double.infinity
let d4 = Double.nan
let d5 = -0.1
// Get the nextDown property values
print(d1.nextDown)
print(d2.nextDown)
print(d3.nextDown)
print(d4.nextDown)
print(d5.nextDown)
Using the nextDown property of double values in Swift

Explanation

  • Lines 2 to 6: We create some double values.
  • Line 9 to 13: We get the nextDown property of the Double instance values, and print them to the console.

RELATED TAGS

swift
double
nextdown
communitycreator
double value

CONTRIBUTOR

Theodore Kelechukwu Onyejiaku

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring