-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add abs, round, floor, ceil operators #6496
Conversation
|
cc @samanpwbb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ceil
in C, C++, JavaScript, Python, and Java so let's stick with that.
'abs': [ | ||
NumberType, | ||
[NumberType], | ||
(ctx, args) => Math.abs(args[0].evaluate(ctx)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer argument destructuring as in the other definitions, i.e. (ctx, [n]) => ...
.
src/style-spec/reference/v8.json
Outdated
@@ -2490,6 +2490,42 @@ | |||
} | |||
} | |||
}, | |||
"round": { | |||
"doc": "Rounds the input to the nearest integer. Halflway values are rounded away from zero. E.g., `[\"round\", -1.5]` evaluates to -2.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Halflway → Halfway
src/style-spec/reference/v8.json
Outdated
@@ -2490,6 +2490,42 @@ | |||
} | |||
} | |||
}, | |||
"round": { | |||
"doc": "Rounds the input to the nearest integer. Halflway values are rounded away from zero. E.g., `[\"round\", -1.5]` evaluates to -2.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: It’s somewhat unusual to begin a sentence with “E.g.” “For example” is more easily understood.
} | ||
}, | ||
"abs": { | ||
"doc": "Returns the absolute value of the input.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when implementing I noticed abs on -1.1
returns 1
, could we include in the documentation that abs is an integer type function/not floating point? (from a java background this was a bit confusing for me).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
capturing from chat that above assumption was invalid
Oh shoot, that’s a bug! Will fix
…On Wed, Apr 11, 2018 at 7:25 AM Tobrun ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/style-spec/reference/v8.json
<#6496 (comment)>:
> @@ -2490,6 +2490,42 @@
}
}
},
+ "round": {
+ "doc": "Rounds the input to the nearest integer. Halflway values are rounded away from zero. E.g., `[\"round\", -1.5]` evaluates to -2.",
+ "group": "Math",
+ "sdk-support": {
+ "basic functionality": {
+ "js": "0.45.0"
+ }
+ }
+ },
+ "abs": {
+ "doc": "Returns the absolute value of the input.",
when implementing I noticed abs on -1.1 returns 1, could we include in
the documentation that abs is an integer type function/not floating point?
(from a java background this was a bit confusing for me).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6496 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEvmR5Sn8Yyk5PGGKqZLchiFC6QChRzzks5tnegwgaJpZM4TPMfA>
.
|
* Add abs, round, floor, ceil operators Port of mapbox/mapbox-gl-js#6496 * [ios, macos] Simplified abs, ceiling, floor expressions * [ios, macos] Added rounding expression function * [android] - binding integration for round, ceil, floor and abs expressions * Update mapbox-gl-js to include non-integer rounding test * Drop extra braces * mapbox-gl-js -> master * Update style-spec docs -> PropertyFactory.java
Refs #5853
TODO: