Overview:
- The nextafter() function in the math module of Python, returns the next floating point number after the begin and before the end.
- If the input numbers are equal the function returns the value of the second parameter.
Example 1:
# Example Python program that finds the next floating point number def printNextFloatInRange(begin, end):
# Next floating point in decreasing range |
Output:
Next floating point number after 1.0000000000000000 and before 2.1000000000000001: 1.0000000000000002 Next floating point number after 2.0000000000000000 and before 3.2000000000000002: 2.0000000000000004 Next floating point number after 3.0000000000000000 and before 4.0000000000000000: 3.0000000000000004 Next floating point number after 3.0000000000000000 and before 4.0999999999999996: 3.0000000000000004 Next floating point number after 1.0000000000000000 and before 0.0000000000000000: 0.9999999999999999 |