Should you be able to initialize a float with a char?
user1234
user1234 at 12.de
Thu May 19 16:07:16 UTC 2022
On Thursday, 19 May 2022 at 14:33:14 UTC, Steven Schveighoffer
wrote:
> On 5/19/22 12:35 AM, Walter Bright wrote:
>> On 5/18/2022 5:47 PM, Steven Schveighoffer wrote:
>>> But I have little hope for it, as Walter treats a boolean as
>>> an integer.
>>
>> They *are* integers.
>>
>> The APL language relies on bools being integers so conditional
>> operations can be carried out without branching :-)
>>
>> I.e.
>> a = (b < c) ? 8 : 3;
>>
>> becomes:
>>
>> a = 3 + (b < c) * 5; // I know this is not APL syntax
>>
>> That works in D, too!
>
> I hope we are not depending on the type system to the degree
> where a bool must be an integer in order to have this kind of
> optimization.
>
> -Steve
if you use bool as integer types in LLVM
true + true
overflows and you basically get 0 because only 1 bit is read.
More information about the Digitalmars-d
mailing list