Skip to content

Discrepancy: number comparison differs from Processing Java (0.1 + 0.2 == 0.3) #203

Description

@SableRaf

I don't know whether this is something that needs to be addressed or just documented.
I suppose this is related to the difference between float and double precision (?)

In Processing, this condition evaluates to true:

void setup() {
  size(400, 400);

  if (0.1 + 0.2 == 0.3) {
    background(0, 255, 0);
    circle(200, 200, 100);
  }
}

The equivalent mewnala sketch evaluates the condition as false.

from mewnala import *

def setup():
    size(200, 200)

    if 0.1 + 0.2 == 0.3:
        background(0, 255, 0)
        circle(200, 200, 100)

run()

Note: size is reduced in mewnala to account for #198

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions