Thread overview | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
August 06, 2003 Quick and easy request: binary literals | ||||
---|---|---|---|---|
| ||||
Allright - octals are pretty useless (or aren't they?), but I was always missing binary literals from C++. Would it break anything if we had binary literals in D? Sometimes it saves a lot of time! |
August 06, 2003 Re: Quick and easy request: binary literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to QUS | Seconded. Why not 0b01010101? Sean "QUS" <qus@go2.pl> wrote in message news:bgr5h8$u9m$1@digitaldaemon.com... > Allright - octals are pretty useless (or aren't they?), but I was always missing binary literals from C++. Would it break anything if we had binary literals in D? Sometimes it saves a lot of time! |
August 06, 2003 Re: Quick and easy request: binary literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | Thirded! >Why not 0b01010101? That first zero kind of makes it hard to read though. Charles "Sean L. Palmer" <palmer.sean@verizon.net> wrote in message news:bgrch4$157i$1@digitaldaemon.com... > Seconded. > > Why not 0b01010101? > > Sean > > "QUS" <qus@go2.pl> wrote in message news:bgr5h8$u9m$1@digitaldaemon.com... > > Allright - octals are pretty useless (or aren't they?), but I was always missing binary literals from C++. Would it break anything if we had binary > > literals in D? Sometimes it saves a lot of time! > > |
August 06, 2003 Re: Quick and easy request: binary literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | "Sean L. Palmer" <palmer.sean@verizon.net> wrote in message news:bgrch4$157i$1@digitaldaemon.com... > Seconded. > > Why not 0b01010101? > > Sean > > "QUS" <qus@go2.pl> wrote in message news:bgr5h8$u9m$1@digitaldaemon.com... > > Allright - octals are pretty useless (or aren't they?), but I was always missing binary literals from C++. Would it break anything if we had binary > > literals in D? Sometimes it saves a lot of time! That exact syntax has been supported by Digital Mars C and C++ for 20 years now. It's even supported as a printf format. To my knowledge, nobody has ever used it. The truth is, it's easier to deal with bit patterns in hex. Quick, what is the value of 0b110010000001000? If you're like me, you stick a penpoint on the screen and count the 0's. So much easier to deal with 0x6408. The only time I found binary notation useful was when I was creating data for a bitmapped cursor <g>. I don't see octal used so much anymore, but a lot of legacy code used it because it mapped well onto the PDP-11 instruction set. Lots of people got used to using octal, and it carried forward into hex computers. |
August 06, 2003 Re: Quick and easy request: binary literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote: > That exact syntax has been supported by Digital Mars C and C++ for 20 years > now. It's even supported as a printf format. To my knowledge, nobody has > ever used it. Because it's not *standard*, man! It's being avoided for portability! Why do you think people use C++? Because it's *standard*. Whatever makes it into D, shall become standard within D. And thus gradually accepted. > The truth is, it's easier to deal with bit patterns in hex. Not always. > Quick, what is the value of 0b110010000001000? If you're like me, you stick > a penpoint on the screen and count the 0's. So much easier to deal with > 0x6408. The only time I found binary notation useful was when I was creating > data for a bitmapped cursor <g>. Argh. You must allow for an underscore in numbers. It shall also do readability of integers and floating-point numbers a lot of good. 0b_11111000_00011111 BTW, does this bitmask ring the bell? Well, things like that are not at all rare, and i don't want to need a bin-hex table at hand all the time! > I don't see octal used so much anymore, but a lot of legacy code used it > because it mapped well onto the PDP-11 instruction set. Lots of people got > used to using octal, and it carried forward into hex computers. The current syntax for octals is horrible anyway. Why don't you make it into 0o123? -i. |
August 06, 2003 Re: Quick and easy request: binary literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charles Sanders | Charles Sanders wrote:
> Thirded!
Sure, make it four.
I have to agree with Walter about the usefulness, but it seems so easy to add...
Bill
|
August 06, 2003 Re: Quick and easy request: binary literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to QUS | Ohh yes. That's a spiffy idea! "QUS" <qus@go2.pl> wrote in message news:bgr5h8$u9m$1@digitaldaemon.com... > Allright - octals are pretty useless (or aren't they?), but I was always missing binary literals from C++. Would it break anything if we had binary literals in D? Sometimes it saves a lot of time! > > |
August 06, 2003 Re: Quick and easy request: binary literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ilya Minkov | "Ilya Minkov" <midiclub@8ung.at> wrote in message news:bgrkfk$1db9$1@digitaldaemon.com... > Walter wrote: > > > That exact syntax has been supported by Digital Mars C and C++ for 20 years > > now. It's even supported as a printf format. To my knowledge, nobody has ever used it. > > Because it's not *standard*, man! It's being avoided for portability! Why do you think people use C++? Because it's *standard*. > > Whatever makes it into D, shall become standard within D. And thus gradually accepted. > That is true! > > The truth is, it's easier to deal with bit patterns in hex. > > Not always. > > > Quick, what is the value of 0b110010000001000? If you're like me, you stick > > a penpoint on the screen and count the 0's. So much easier to deal with 0x6408. The only time I found binary notation useful was when I was creating > > data for a bitmapped cursor <g>. > > Argh. You must allow for an underscore in numbers. It shall also do readability of integers and floating-point numbers a lot of good. > > 0b_11111000_00011111 > Kind of silly looking, maybe whitespace something like string literals: 0b 11111000 00011111 I can't think of anything off the top of my head that would break with this. > BTW, does this bitmask ring the bell? Well, things like that are not at all rare, and i don't want to need a bin-hex table at hand all the time! > > > I don't see octal used so much anymore, but a lot of legacy code used it because it mapped well onto the PDP-11 instruction set. Lots of people got > > used to using octal, and it carried forward into hex computers. > > The current syntax for octals is horrible anyway. Why don't you make it into 0o123? > > -i. > For my opinion on binary literals: I've learned to live with using hex so it won't really bother me either way, but it does seem like a good idea to add. |
August 06, 2003 Re: Quick and easy request: binary literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ilya Minkov | > Argh. You must allow for an underscore in numbers. It shall also do readability of integers and floating-point numbers a lot of good.
>
> 0b_11111000_00011111
What an amazing and obvious idea. I can't believe no-one's thought of it before.
Please can we allow this syntax for all integer literals (of whatever base)
in D!?
|
August 07, 2003 Re: Quick and easy request: binary literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | Matthew Wilson wrote:
>>Argh. You must allow for an underscore in numbers. It shall also do
>>readability of integers and floating-point numbers a lot of good.
>>
>>0b_11111000_00011111
>
>
> What an amazing and obvious idea. I can't believe no-one's thought of it
> before.
See Ada.
|
Copyright © 1999-2021 by the D Language Foundation