Fix rounding of negative numbers #825

Closed
rigdern wants to merge 1 commits from rigdern/round-negative into master
rigdern commented 2018-10-09 15:26:05 -07:00 (Migrated from github.com)

YGRoundValueToPixelGrid currently rounds negative numbers incorrectly. For example:

YGRoundValueToPixelGrid(-2.2, 1.0, /* ceil */ false, /* floor */ true) = -2.0

However, that operation is supposed to take the floor of the number so the result should acutally be -3.0.

There's a detailed comment in YGRoundValueToPixelGrid about the fix and why it works.

A symptom that manifested because of this bug is that text nodes could get smaller and smaller on each layout pass. For details see https://github.com/facebook/yoga/issues/824.

Fixes #824

Adam Comella
Microsoft Corp.

`YGRoundValueToPixelGrid` currently rounds negative numbers incorrectly. For example: ``` YGRoundValueToPixelGrid(-2.2, 1.0, /* ceil */ false, /* floor */ true) = -2.0 ``` However, that operation is supposed to take the floor of the number so the result should acutally be `-3.0`. There's a detailed comment in `YGRoundValueToPixelGrid` about the fix and why it works. A symptom that manifested because of this bug is that text nodes could get smaller and smaller on each layout pass. For details see https://github.com/facebook/yoga/issues/824. Fixes #824 Adam Comella Microsoft Corp.
facebook-github-bot (Migrated from github.com) reviewed 2018-10-09 16:24:06 -07:00
facebook-github-bot (Migrated from github.com) left a comment

shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

shergin has imported this pull request. If you are a Facebook employee, you can view this diff [on Phabricator](https://phabricator.internmc.facebook.com/D10282064).

Pull request closed

Sign in to join this conversation.
No description provided.