!tDnwWRNkmmYtMXfaZl:nixos.org

Nix Language

1920 Members
Nix programming language357 Servers

Load older messages


SenderMessageTime
4 Jun 2026
@alexfmpe:matrix.orgalexfmpeIt might be 'increment the exponent' or it might be a completely different mantissa with a completely different exponent11:28:59
@alexfmpe:matrix.orgalexfmpeImagine computing the 'next rational' when denominator and numerator only go up to 2^32 or whatever11:29:38
@alexfmpe:matrix.orgalexfmpeFor floats it's similar to that but instead of quotients you're dealing with exponentiation11:30:14
@piegames:flausch.socialpiegames @alexfmpe:matrix.org those are orthogonal concerns to the original question. And yes, this is computable, and commonly provided by libraries under the name "nextafter" 11:41:18
@alexfmpe:matrix.orgalexfmpeWell sure you can compute it, it's just not obvious to me how to do it efficiently since there's essentially two knobs to turn in the binary representation 11:49:23
@alexfmpe:matrix.orgalexfmpeSure, "nextafter" probably does it efficiently11:50:24
@xokdvium:matrix.orgSergei Zimmerman (xokdvium)Don't think there's an efficient hack to split a double into its significand/exponent11:54:48
@xokdvium:matrix.orgSergei Zimmerman (xokdvium)Reconstructing it should be quite easy11:55:15
@alexfmpe:matrix.orgalexfmpeWonder if you can do newton's method. Make a finite guess, average the guess and original number, make that the new guess and repeat until the output is one of the inputs12:02:36
@alexfmpe:matrix.orgalexfmpeIt's kinda binary search, so proporcional to number of bits or something, not great not terrible12:03:02
@alexfmpe:matrix.orgalexfmpeer, more like quadratic since O(n) operations with N bits12:03:30
@xokdvium:matrix.orgSergei Zimmerman (xokdvium)Hm yeah the exponent range is small12:03:39
@xokdvium:matrix.orgSergei Zimmerman (xokdvium)It's just 11 bits12:03:49
@alexfmpe:matrix.orgalexfmpeBut we treat word size as O(1) in practice12:03:55
@alexfmpe:matrix.orgalexfmpe
In reply to @xokdvium:matrix.org
Hm yeah the exponent range is small
Well I'm not leveraging anything about the binary structure here
12:04:18
@alexfmpe:matrix.orgalexfmpeYou won't enumerate all floats by just enumerating the exponent12:04:34
@alexfmpe:matrix.orgalexfmpeSo at some point 'nextafter' has to touch the mantissa12:04:47
@xokdvium:matrix.orgSergei Zimmerman (xokdvium)But to get the nextafter you just +1 to the mantissa's binary representation12:05:18
@alexfmpe:matrix.orgalexfmpeWhy?12:05:31
@alexfmpe:matrix.orgalexfmpeAlso this is super offtopic, maybe continue in a thread?12:05:50
@xokdvium:matrix.orgSergei Zimmerman (xokdvium)(Or increment the exponent if the mantissa would overflow)12:05:51
@xokdvium:matrix.orgSergei Zimmerman (xokdvium)Sure12:06:06
@alexfmpe:matrix.orgalexfmpeWhy is incrementing the mantissa expected to always yield a smaller number than incrementing the exponent?12:07:23
@alexfmpe:matrix.orgalexfmpeIncreasing the base of a large exponent should yield greater increases than the large exponent12:08:32
@alexfmpe:matrix.orgalexfmpe2^4=16 2^5=32 3^4=8112:09:02
@alexfmpe:matrix.orgalexfmpeIt's a 2D thing, no way around it12:09:26
@xokdvium:matrix.orgSergei Zimmerman (xokdvium)I mean, you want to increment by 1 ulp https://en.wikipedia.org/wiki/Unit_in_the_last_place12:10:46
@xokdvium:matrix.orgSergei Zimmerman (xokdvium)There's a different with subnormals, since the exponent is computed differently12:11:29
@xokdvium:matrix.orgSergei Zimmerman (xokdvium)https://github.com/boostorg/math/blob/febada30785cb1e5ffb61d817e7d1a4b8985e544/include/boost/math/special_functions/next.hpp#L206-L20912:14:35
@lumi:the-apothecary.club@lumi:the-apothecary.club changed their profile picture.12:17:44

Show newer messages


Back to Room ListRoom Version: 6