Re: Phix: float32 return value

new topic     » goto parent     » topic index » view thread      » older message
petelomax said...

Oh, OK, if it's alright with you I'll put the release on hold then, and press on with other things (such as further investigating bool returns).

Just a few thoughts...

Unfortunately, I had to delve deeply into the MS-ABI (not the MS Win32 API) specifically the AMD64 MS-ABI.

Of course, whether you like it or not, the C programming language is the deciding factor here. The 'bool' data type is unknown in C and was therefore represented as an integer: 0 = false, 1 = true. With C99, a fixed definition was introduced via stdbool.h that did exactly that. This replaced the internal keyword _Bool.

stdbool.h has been deprecated since C23. I don't know at the moment how things will proceed from here.

A simple definition of bool (used in many PLC systems) is that if the least significant bit is 1, it is true; if it is 0, it is false.

The problem with all ABIs is that it's not guaranteed that the irrelevant bits will be cleared. A bool can be 1 byte, 2 bytes, 4 bytes, or even 8 bytes in 64-bit systems. But as far as I've seen, there's no specification anywhere that requires clearing the irrelevant bits.

I think 'and_bits(result, 1)' is the best solution available.

However, this also means that if 'result' were 2, the result would be false.

And many checks like 'if (result) then' would, understandably, no longer work.

These are just my thoughts.

And, since I use a translation tool, it's really a pain that the forum crashes every time I use a Unicode character.

new topic     » goto parent     » topic index » view thread      » older message

Search



Quick Links

User menu

Not signed in.

Misc Menu