Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 20ab1b63b4bfc1418e7536a2d4c6d6879dbf80921673497db2a9ca4ba83fc5f0
Ticket: 713653b951c625ef974f5f06b2e96634ca5fb1f9
Floating point precision problems on x86 musl
User & Date: rubicon on 2022-07-15 11:54:27
Changes

  1. icomment:
    After a bit of trial and error, I zeroed in on what happens before a return from `MakeLowPrecisionDouble`, and found that the `TCL_DEFAULT_DOUBLE_ROUNDING` macro runs before `return retval;` but not before `return copysign(0.0, -signum);`.
    
    
    By adding that to make the code that I was commenting out look like this (of course, no longer commented out now):
    ```
        if (significand == 0) {
    	TCL_DEFAULT_DOUBLE_ROUNDING;
    	return copysign(0.0, -signum);
        }
    ```
    
    The problem with Tcl's expr-old and format tests is solved.
    
    I will try it with Tcllib's math and units tests shortly, if I don't say anything else it means they pass too.
    
    I guess this probably means glibc resets the rounding mode automatically, but musl doesn't.
    
    I see something similar happens with `MakeHighPrecisionDouble`, but I'll leave it to those more knowledgeable than me to determine if the `TCL_DEFAULT_DOUBLE_ROUNDING` needs to be added there as well.
    
  2. login: "rubicon"
  3. mimetype: "text/x-markdown"