Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
vidjil
vidjil
Commits
57ff9d65
Commit
57ff9d65
authored
Aug 08, 2018
by
Mathieu Giraud
Browse files
js/tools.js: nice_1_2_5_ceil(), round up to a very nice number
See
#2699
.
parent
1710e19b
Changes
1
Hide whitespace changes
Inline
Side-by-side
browser/js/tools.js
View file @
57ff9d65
...
...
@@ -313,6 +313,27 @@ function nice_ceil(x, force_pow10)
}
/**
* Give a nice decimal number (to 1/2/5) above the given number
**/
function
nice_1_2_5_ceil
(
x
)
{
if
(
x
<=
0
)
return
x
try
{
var
floor_power10
=
floor_pow10
(
x
)
var
xx
=
x
/
floor_power10
return
(
xx
==
1
?
1
:
xx
<=
2
?
2
:
xx
<=
5
?
5
:
10
)
*
floor_power10
}
catch
(
e
)
{
// Always return something
return
x
;
}
}
/**
* Give a nice decimal number under the given number
* nice_floor(0.14) -> 0.1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment