Why this FCMP OEQ is false?

I wrote a simple program but I don’t understand why but this is outputting false, even I thought that this should be true.

; ModuleID = '../../main.n'
source_filename = "../../main.n"
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"

@0 = private unnamed_addr constant [15 x i8] c"Result: {13:1}\00", align 1

define dso_local void @main() {
entry:
  %0 = alloca i1, align 1
  %1 = fsub double 5.300000e+00, 5.200000e+00
  %2 = fcmp oeq double %1, 1.000000e-01
  store i1 %2, ptr %0, align 1
  %3 = load i1, ptr %0, align 1
  call void (ptr, ...) @print(ptr @0, i1 %3)
  ret void
}

declare void @print(ptr, ...)

Thanks a lot for any reply.

0.1, 5.2 and 5.3 can’t be represented exactly with binary fractions, so this introduces imprecision in %1 compared with what the infinite-precision version would give. The inability to represent 0.1 exactly is the source of a rather famous and unfortunate failure in a Patriot missile where the error accumulated over time and resulted in the inability to intercept an incoming missile.

How could I eliminate that? How do other languages handle this kind of imprecision? Do they floor or something I’m unable to find on the web myself?

You can’t and they don’t. Imprecision is a fact of floating-point arithmetic and needs to be carefully reasoned about through various mathematical techniques. I’d suggest finding educational resources online about this.

You are right, other languages I’ve tested right now behave the same way. At least I know that this isn’t a mistake made by me.

You may find the following guide a helpful explanation to floating point and its seeming idiosyncrasies: https://www.phys.uconn.edu/~rozman/Courses/P2200_15F/downloads/floating-point-guide-2015-10-15.pdf