Thread overview
int to bit
May 13, 2005
Ant
May 13, 2005
Derek Parnell
May 13, 2005
Ant
May 13, 2005
Peter Mackay
May 13, 2005
Stewart Gordon
May 13, 2005
cannot implicitly convert expression ...... of type int to bit

is this new?

Window 2000, dmd 0.123

Ant


May 13, 2005
On Fri, 13 May 2005 03:50:08 +0000 (UTC), Ant wrote:

> cannot implicitly convert expression ...... of type int to bit
> 
> is this new?
> 
> Window 2000, dmd 0.123

No, I don't think so.

You can't implicitly convert float to int either.

-- 
Derek
Melbourne, Australia
13/05/2005 2:06:42 PM
May 13, 2005
Derek Parnell wrote:
> On Fri, 13 May 2005 03:50:08 +0000 (UTC), Ant wrote:
> 
> 
>>cannot implicitly convert expression ...... of type int to bit
>>
>>is this new?
>>
>>Window 2000, dmd 0.123
> 
> 
> No, I don't think so. 
> 
> You can't implicitly convert float to int either.
> 
rebooted to linux.

it's ok for dmd 0.121 linux
downloading dmd 0.123...installing...ok

still passes on linux dmd 0.123.


from phobos:

class Object
{
    void print();
    char[] toString();
    uint toHash();
    int opCmp(Object o);
    int opEquals(Object o);
}

why does opEquals return an int?

(all my "int to bit" were from "==")

Ant

May 13, 2005
Hello,

> why does opEquals return an int?

I think because it's faster. Otherwise the machine, which deals with int sizes well (typically because they're native word sized), would have to convert between int and bits all the time.

The int vs bit vs bool argument has been bashed out on the group a lot I suspect. It's not how I'd like it either, but I think it's just 'how it is'.

> (all my "int to bit" were from "==")

I get this too, since I usually have functions return a bool for my own readability, and have to add a cast manually.

Pete
May 13, 2005
Peter Mackay wrote:
> Hello,
> 
>> why does opEquals return an int?
> 
> 
> I think because it's faster. Otherwise the machine, which deals with int sizes well (typically because they're native word sized), would have to convert between int and bits all the time.
<snip>

But isn't a single bit (as opposed to a bit array) represented internally as an int anyway?

Stewart.

-- 
My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
May 13, 2005
"Stewart Gordon" <smjg_1998@yahoo.com> wrote in message news:d62k80$2fn0$1@digitaldaemon.com...
> But isn't a single bit (as opposed to a bit array) represented internally as an int anyway?

bit.sizeof is 1, so it's probably represented as a byte.