Skip to content
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

FEAT: switch pair! from integer! to float32! #4049

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

bitbegin
Copy link
Collaborator

No description provided.

@qtxie
Copy link
Contributor

qtxie commented Sep 24, 2019

We still need to support float pair! in the compiler lexer.

@hiiamboris
Copy link
Collaborator

Just curious here :)
Have you considered using a pair of 32-bit integers instead of float-32?
IMO, range from -2147483.648 to 2147483.647 should cover every possible graphics need, even with all the intermediary computation results.
It's just that using floats you open a pandora's box of NaNs, INFs, rounding, and inexact arithmetic.
Is there a reason why float should be preferred to integer in pair's case?

@qtxie
Copy link
Contributor

qtxie commented Sep 24, 2019

Have you considered using a pair of 32-bit integers instead of float-32?

It is 32-bit integers in current implementation.

It's just that using floats you open a pandora's box of NaNs, INFs, rounding, and inexact arithmetic.

You have those problems too using integers. Even worse, using integers you lost precision in many places. e.g DRAW dialect, font size.

@hiiamboris
Copy link
Collaborator

@qtxie in the above I'm implying that the last 3 digits of the integer can be used as a fractional part. To put it another way, 1/1000 of a pixel minimum increment size. The same tactic that's used for the money datatype, really.

@qtxie
Copy link
Contributor

qtxie commented Sep 24, 2019

@hiiamboris Ah, Ok. You mean a custom decimal format. That needs more work. Also most of the modern OSes use float32! in their Graphic APIs. Using float32! make it easier to integrated with the OS APIs.

@hiiamboris
Copy link
Collaborator

I see. Thanks for the info :)

@qtxie
Copy link
Contributor

qtxie commented Sep 24, 2019

Some notes about this change:
Pros:

  1. More accurate drawing in DRAW.
  2. More accurate offset and size. E.g. face/offset, font/size.

Cons:

  1. Integer pair works better for images.
  2. No bitwise operations. (and, or, xor)

Using float32 pair we can work around those Cons by converting pair/x and pair/y to integer first.
While we cannot have the Pros using integer pair.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants