Thread overview | ||||||
---|---|---|---|---|---|---|
|
June 21, 2010 [phobos] phobos commit, revision 1674 | ||||
---|---|---|---|---|
| ||||
phobos commit, revision 1674 user: Don Clugston msg: Two more B stings. http://www.dsource.org/projects/phobos/changeset/1674 |
June 21, 2010 [phobos] phobos commit, revision 1674 | ||||
---|---|---|---|---|
| ||||
Posted in reply to dsource.org | >From the numeric.d diff line 365 (and others), should we have code that relies on the implicit casting of bool to 1 or 0? I find that kind of code disturbing, but maybe it's just me. I'd rather see something like: return cast(size_t) log10( 1uL << precision - ((flags&Flags.storeNormalized) != 0 ? 1 : 0)); But that looks crappy too (though less disturbing). What do others think? -Steve ----- Original Message ---- > From: dsource.org <noreply at dsource.org> > To: phobos at puremagic.com > Sent: Mon, June 21, 2010 4:22:19 PM > Subject: [phobos] phobos commit, revision 1674 > > phobos commit, revision 1674 user: Don Clugston msg: Two > more B stings. http://www.dsource.org/projects/phobos/changeset/1674 _______________________________________________ phobos > mailing list > href="mailto:phobos at puremagic.com">phobos at puremagic.com http://lists.puremagic.com/mailman/listinfo/phobos |
June 21, 2010 [phobos] phobos commit, revision 1674 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steve Schveighoffer | I kind of like being able to cast bool to an integer, but I realize it's a bit low-level.
Andrei
On 06/21/2010 04:39 PM, Steve Schveighoffer wrote:
> From the numeric.d diff line 365 (and others), should we have code that relies on the implicit casting of bool to 1 or 0? I find that kind of code disturbing, but maybe it's just me. I'd rather see something like:
>
> return cast(size_t) log10( 1uL<< precision - ((flags&Flags.storeNormalized) != 0 ? 1 : 0));
>
> But that looks crappy too (though less disturbing). What do others think?
>
> -Steve
>
>
>
> ----- Original Message ----
>> From: dsource.org<noreply at dsource.org>
>> To: phobos at puremagic.com
>> Sent: Mon, June 21, 2010 4:22:19 PM
>> Subject: [phobos] phobos commit, revision 1674
>>
>> phobos commit, revision 1674
>
>
> user: Don Clugston
>
> msg:
> Two
>> more B
>> stings.
>
> http://www.dsource.org/projects/phobos/changeset/1674
>
> _______________________________________________
> phobos
>> mailing list
>
>> href="mailto:phobos at puremagic.com">phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
>
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
|
June 21, 2010 [phobos] phobos commit, revision 1674 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steve Schveighoffer | I think it's safe. In addition to being documented by the spec, I tried to get something other than a 1 or 0 into a bool and failed. Implicit conversions of integer values other than 1 and 0 are disallowed, and casting an arbitrary number to bool changes it to 0/1. I find this preferable to languages with looser definitions where comparing two logically true boolean values may return false. IOWs, since we're afforded this benefit we may as well use it.
On Jun 21, 2010, at 2:39 PM, Steve Schveighoffer wrote:
> From the numeric.d diff line 365 (and others), should we have code that relies on the implicit casting of bool to 1 or 0? I find that kind of code disturbing, but maybe it's just me. I'd rather see something like:
>
> return cast(size_t) log10( 1uL << precision - ((flags&Flags.storeNormalized) != 0 ? 1 : 0));
>
> But that looks crappy too (though less disturbing). What do others think?
>
> -Steve
>
>
>
> ----- Original Message ----
>> From: dsource.org <noreply at dsource.org>
>> To: phobos at puremagic.com
>> Sent: Mon, June 21, 2010 4:22:19 PM
>> Subject: [phobos] phobos commit, revision 1674
>>
>> phobos commit, revision 1674
>
>
> user: Don Clugston
>
> msg:
> Two
>> more B stings.
>
> http://www.dsource.org/projects/phobos/changeset/1674
>
> _______________________________________________
> phobos
>> mailing list
>
>> href="mailto:phobos at puremagic.com">phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
>
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
|
Copyright © 1999-2021 by the D Language Foundation