Skip to content

%.16d processing does the zero padding inappropriately early #571

Closed
@duffy-ocraven

Description

@duffy-ocraven
module Issue_571;

import spicy;

public type Stream = unit {
    floats: oneFloat[];
};

const FLOAT_SIZE = 8;
type oneFloat = unit {
  data: bytes &size=FLOAT_SIZE;
  asDouble: real &type=spicy::RealType::IEEE754_Double &parse-from = self.data;
    on %done {
      print ("for the inf's and nan %%.16d prints %.16d" % (self.asDouble,));
      print ("for the inf's and nan %%.16g prints %.16g" % (self.asDouble,));
      print ("for the inf's and nan %%.16f prints %.16f" % (self.asDouble,));
    }
};

produces

$ printf "\377\370\000\000\000\000\000\000" | ../spicy/build/bin/spicy-driver Issue_571.spicy
for the inf's and nan %.16d prints 0000000000000nan
for the inf's and nan %.16g prints nan
for the inf's and nan %.16f prints nan

$ printf "\377\360\000\000\000\000\000\000" | ../spicy/build/bin/spicy-driver Issue_571.spicy
for the inf's and nan %.16d prints -000000000000inf
for the inf's and nan %.16g prints -inf
for the inf's and nan %.16f prints -inf

$ printf "\377\350\000\000\000\000\000\000" | ../spicy/build/bin/spicy-driver Issue_571.spicy
for the inf's and nan %.16d prints -1.348269851146737e+308
for the inf's and nan %.16g prints -1.348269851146737e+308
for the inf's and nan %.16f prints -134826985114673693079697889309176855021348273420672992955072560868299506854125722349531357991805652015840085409903545018244092326610812466869635572979605593283325920068649113957226664700934570589589812214063754326628613011756847161105434832905620427872512883013439723679960434453859787228626517247218168102912.0000000000000000

Activity

bbannier

bbannier commented on Nov 6, 2020

@bbannier
Member

This is an issue in the library we use for formatting. I created an upstream issue, c42f/tinyformat#76.

bbannier

bbannier commented on Nov 11, 2020

@bbannier
Member

A first fix for this has been merged upstream, c42f/tinyformat#77. It looks like we still need something along the lines of c42f/tinyformat#78 to be able to consume that version though.

self-assigned this
on Nov 11, 2020
added this to the Spicy 1.0 milestone on Nov 12, 2020
bbannier

bbannier commented on Nov 13, 2020

@bbannier
Member

This is now unblocked since the upstream issue was fixed by c42f/tinyformat#80.

added a commit that references this issue on Nov 16, 2020
ff0fbdc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    %.16d processing does the zero padding inappropriately early · Issue #571 · zeek/spicy