www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - int to bit

reply Ant <Ant_member pathlink.com> writes:
cannot implicitly convert expression ...... of type int to bit

is this new?

Window 2000, dmd 0.123

Ant
May 12 2005
parent reply Derek Parnell <derek psych.ward> writes:
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 12 2005
parent reply Ant <duitoolkit yahoo.ca> writes:
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 12 2005
parent reply Peter Mackay <a_pointy_stick.NoJunkMail yahoo.co.uk> writes:
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
parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
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
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"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.
May 13 2005