Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 6b0bb28d78a0c30ebbfd546d87b30721c834812d51687bb400e5074845dc7484
Ticket: 42d14c495a096159841d2601a16850273713b31b
Parsing long floating point strings
User & Date: chw on 2023-09-22 09:16:17
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-plain"
  4. comment changed to:
    The following snippet gives strange results when the mantissa gets large enough:
    
    for {set i 1} {$i < 1000} {incr i} {
        set s 1.[string repeat 1 $i]e-321
        set d ""
        scan $s %g d
        if {$d eq ""} break
        puts [format "%3d: %.20g" $i $d]
        if {$d == inf || $d == -inf} break
    }
    
    Output on x86_64 Linux for 8.6.11, core-8-branch, trunk:
    
      1: 1.1017663902259797935e-321
      2: 1.1116477031428047244e-321
    ...
    190: 1.1116477031428047244e-321
    191: 8.2870452568891190738e+36
    ...
    701: -1.6598062275523971834e+181
    702: 8.2870452568891190738e+36
    703: inf
    
    Expectation: like C library sscanf(str, "%lg", &d), i.e.
    
    ...
    703: 1.1116477031428047244e-321
    ...
    999: 1.1116477031428047244e-321
    
  5. foundin changed to: ">= 8.6"
  6. is_private changed to: "0"
  7. login: "chw"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "1f3e737132a26109e72276643b4e9814a2e846d1"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "chw"
  14. subsystem changed to: "48. Number Handling"
  15. title changed to: "Parsing long floating point strings"
  16. type changed to: "Bug"