Skip to content

Commit

Permalink
Fix floating point rounding error.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramirisu committed Feb 16, 2024
1 parent e1a9a81 commit ba2e159
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/pages/Result.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const Result = () => {
xll: '24px',
})[screens.size]

const getDiffColor = (diff) => (diff <= 0.1 ? 'green' : diff <= 0.2 ? 'orange' : 'red')
const getDiffColor = (diff) => (diff <= 10 ? 'green' : diff <= 20 ? 'orange' : 'red')

if (!isApiVersionOK) {
return (
Expand Down Expand Up @@ -250,7 +250,7 @@ const Result = () => {
>
<Row>
{getTopScores(getIdeologyMatchScores(weights), expandIdeology, 3).map((value, index) => {
const diff = value.diff.toFixed(2)
const diff = Math.round(100 * value.diff)
const linkRC = `quiz.result.ideologies.data.${value.id}.link`
const link = i18n.exists(linkRC) ? t(linkRC) : null
const createLabel = () => (
Expand Down Expand Up @@ -278,7 +278,7 @@ const Result = () => {
textAlign: 'center',
}}
>
{`${100 * diff}%`}
{`${diff}%`}
</Text>
</>
)
Expand Down

0 comments on commit ba2e159

Please sign in to comment.