Comments (6)
Another option not mentioned above is working the same as (3), but returning +0.0
for +0.0
and -0.0
for -0.0
.
Essentially, sign(x) = if x > 0.0 { type(x)(1) } else if x < -0.0 { type(x)(-1) } else { x }
. I do believe this option has the most applicability in the widest range of use cases, as it aligns with the mathematical definition while keeping the flexibility of (2) — you get to differentiate between 0+ and 0- where that's required and elsewhere just use == 0
for a straightforward 0 check.
from typst.
Another option not mentioned above is working the same as (3), but returning
+0.0
for+0.0
and-0.0
for-0.0
. Essentially,sign(x) = if x > 0.0 { type(x)(1) } else if x < -0.0 { type(x)(-1) } else { x }
. I do believe this option has the most applicability in the widest range of use cases, as it aligns with the mathematical definition while keeping the flexibility of (2) — you get to differentiate between 0+ and 0- where that's required and elsewhere just use== 0
for a straightforward 0 check.
I don't think that's particularly useful, since #(float("+0.0") == float("-0.0"))
returns true
, so it's easier to just return +0 for both cases.
from typst.
Since when do we prefer 'easier' approaches? /lh
My point is that for almost all use cases this is indistinguishable from (3), but if someone really needs to differentiate 0+ and 0- they still can.
from typst.
As said somewhere else, I'd prefer to have calc removed in favor of methods on int and float, so any potential discussion should take this possibility into account.
from typst.
As said somewhere else, I'd prefer to have calc removed in favor of methods on int and float, so any potential discussion should take this possibility into account.
I think that could definitely be suitable in this case, given that the behavior would differ between integers and floats. We could have int.signum()
and float.signum()
.
from typst.
I'd say this favors a design where calc.signum returns a number of the type it was given.
from typst.
Related Issues (20)
- SVG renders with weird gaps in PDF export HOT 3
- GIR: Generic Intermediate Representation HOT 2
- Assign Diagnostics with Identifiers HOT 23
- First line indent after the block equation HOT 2
- Support fraction as block height
- Cannot retrieve spacing from block HOT 2
- Allow description sentences on new lines in terms list HOT 7
- Proposal: change `leading` option to `line-height` HOT 7
- Font encoding issues for non-latin text
- [proposal] Sugar syntax for constructing `ratio` variables from `float` and `int` HOT 3
- Allow `measure` to accept available size HOT 2
- Element with no content followed by `pad` can force breakable block to create an empty frame
- PR proposal: Balanced ragged text HOT 1
- `measure()` treats objects in `rotate(reflow: true, …)` as zero-width HOT 3
- Numbered lines/paragraphs are automatically converted to lists
- Embed/Attach whole pages of PDF files HOT 5
- Pre-built macOS binary of version 0.11.1 doesn't run (requires a Homebrew install of liblzma) HOT 2
- stylistic sets with Zapfino HOT 8
- Feature: Make "let" keyword for variable assignments in code blocks optional HOT 19
- Quote attribution not part of block
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typst.