Closed
Description
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
Metadata
Metadata
Assignees
Labels
No labels
Activity
bbannier commentedon Nov 6, 2020
This is an issue in the library we use for formatting. I created an upstream issue, c42f/tinyformat#76.
bbannier commentedon Nov 11, 2020
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.
bbannier commentedon Nov 13, 2020
This is now unblocked since the upstream issue was fixed by c42f/tinyformat#80.
Fix padding handling when formatting nan and inf values.