Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lucas Silva
committed
Aug 2, 2021
1 parent
1b3a13a
commit 26c31b7
Showing
9 changed files
with
42 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default function getRoundedValue(number: number): number { | ||
if(number > 0){ | ||
return Math.floor(number) | ||
} else { | ||
const result = Math.ceil(number) | ||
return Object.is(result, -0) ? 0 : result | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// @flow | ||
/* eslint-env mocha */ | ||
|
||
import assert from 'power-assert' | ||
import getRoundedValue from '.' | ||
|
||
describe('getRoundedValue', () => { | ||
|
||
it("floor rounds if argument is greater than 0", () => { | ||
const result = getRoundedValue(1.95) | ||
assert(result === 1) | ||
}) | ||
|
||
it("ceil rounds if argument is less than 0", () => { | ||
const result = getRoundedValue(-0.99) | ||
assert(result === 0) | ||
}) | ||
|
||
it("returns 0 if the argument is rounded to -0 #2555", () => { | ||
const result = getRoundedValue(-0.003) | ||
assert(Object.is(result, 0)) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.