DEV Community

Discussion on: Daily Challenge #49 - Dollars and Cents

Collapse
 
tiash990 profile image
Tiash

I'm not sure, but I think that "Sprintf" rounds to nearest integer.
Try with a value like 3.149 if still returns 3.14 or 3.15

Collapse
 
dak425 profile image
Donald Feury

Added additional test case to clarify current rounding behavior.

Collapse
 
dak425 profile image
Donald Feury • Edited

Yeah it rounds to the nearest cent in this case, the question becomes then do we want it to work that way, or do we say "Hey you don't have a full cent" so it always rounds down?