Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,323
    • Issues 4,323
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 376
    • Merge Requests 376
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #9564

Closed
Open
Opened Sep 07, 2014 by jrp2014@jrp2014Reporter

Floating point subnormals overrounded on output

The following test suggests that GHC is overrounding Float subnormals, when printing them out

Prelude> 2**(-149)
1.401298464324817e-45
Prelude> 2**(-149) :: Float
1.0e-45
Prelude> isDenormalized it
True
Prelude>
Prelude> 2**(-149) * 2**(100) * 2**(49) :: Float
1.0

By comparison

#include <stdio.h>
#include <stdlib.h>

int main (void)
{
 float clang_dec, clang_hex, libc_dec, libc_hex;

 clang_dec = 1.401298464324817e-45;
 clang_hex = 0x0.000002P-126;
 printf("clang (from decimal)   = %a\n",clang_dec);
 printf("clang (from decimal)   = %g\n",clang_dec);
 printf("clang (from hex)       = %a\n",clang_hex);
 printf("clang (from hex)       = %g\n",clang_hex);

 libc_dec = strtod("1.401298464324817e-45",NULL);
 libc_hex = strtod("0x0.000002P-126",NULL);
 printf("libc (from decimal) = %a\n",libc_dec);
 printf("libc (from decimal) = %g\n",libc_dec);
 printf("libc (from hex)     = %a\n",libc_hex);
 printf("libc (from hex)     = %g\n",libc_hex);
}

produces

clang (from decimal)   = 0x1p-149
clang (from decimal)   = 1.4013e-45
clang (from hex)       = 0x1p-149
clang (from hex)       = 1.4013e-45
libc (from decimal) = 0x1p-149
libc (from decimal) = 1.4013e-45
libc (from hex)     = 0x1p-149
libc (from hex)     = 1.4013e-45
Trac metadata
Trac field Value
Version 7.8.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Runtime System
Test case
Differential revisions
BlockedBy
Related
Blocking
CC simonmar
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#9564