Re: Quick way to convert Integers to Binary in TCL
- From: skuhagen@xxxxxx
- Date: Sun, 29 Jul 2007 23:18:26 -0700
Mahurshi Akilla wrote:
Is there a quick way to convert integers to binary in TCL? (Without
writing our own proc to do this)
None, that I'm aware of (maybe in some of the math-packages?). But
whats wrong with writing an own proc for it, when it is that simple?:
proc toBinaryString {val} {
set result [expr {($val==0)?0:""}]
while { $val != 0 } {
set result "[expr {($val&1)?1:0}]${result}"
set val [expr {$val>>1}]
}
return $result
}
Regards
Stephan
.
- References:
- Quick way to convert Integers to Binary in TCL
- From: Mahurshi Akilla
- Quick way to convert Integers to Binary in TCL
- Prev by Date: Quick way to convert Integers to Binary in TCL
- Next by Date: Re: Quick way to convert Integers to Binary in TCL
- Previous by thread: Quick way to convert Integers to Binary in TCL
- Next by thread: Re: Quick way to convert Integers to Binary in TCL
- Index(es):
Relevant Pages
|