Closed mgrojo closed 7 months ago
I implemented it like that intentionally after encountering this bug on stream. Even though it's pretty unrelated to Flooring, but it broke all my trust to Ada, and I simply trust C more to handle my floats, sorry. How am I suppose to use this language for mission critical applications I have no idea. :pensive:
Ouch, that hurts!
But that should not break your trust in Ada. FSF GNAT 12 is failing to report the error in your code when using -gnat2022
. I guess it's too old for the Ada 2022 mode (the standard was just published!):
$ x86_64-linux-gnu-gcc-12 --version
x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
Copyright (C) 2022 Free Software Foundation, Inc.
[...]
If you remove that switch:
gnatmake main.adb
x86_64-linux-gnu-gcc-12 -c main.adb
main.adb:6:35: error: invalid operand types for operator "Mod"
main.adb:6:35: error: left operand has type "Standard.Float"
main.adb:6:35: error: right operand has type universal real
gnatmake: "main.adb" compilation error
If you fix those errors, the same compiler and the same switch compiles correctly:
The reason for the compilation error is that mod
and rem
are only defined for integer types, not floating point types or any real number type in general.
https://www.adaic.com/resources/add_content/standards/22rm/html/RM-4-5-5.html
If you upgrade to FSF GNAT 13, the problem is fixed, you can now use -gnat2022
and the compilation error is reported:
By the way, mission-critical application developers don't use the bleeding edge technologies, they upgrade when more adventurous developers have already matured the product :wink:
Summary:
I hope your trust in Ada is restored :smile:
Why are you blaming Ada for you using integer mod on floats?
I hope your trust in Ada is restored 😄
No, I'm sorry. The trust is broken beyond repair. Nothing can be done at this point.
https://en.wikibooks.org/wiki/Ada_Programming/Attributes/%27Floor