Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to test binary format command?

Status
Not open for further replies.

darshadow

Technical User
Dec 14, 2010
11
CH
Hi,

I'm new in tcl programming and I'm trying to understand the binary command!
For a test I want to see the conversion from this value : ex. 300c020 but how could I see th result in binary?
Code:
set var "300c020
set binar [ binary format "H*" $var ]
puts "result : $binar"

Thanks in advance
 
Actually, I can't really tell if this is right but it's something like this. I always have to play around with it.
Code:
% set a 300c020
300c020
% set b [binary format H $a]
0
% set b [binary format 7H $a]
bad field specifier "7"
% set b [binary format H7 $a]
0♀☻
% binary scan $b B28 c
1
% set c
0011000000001100000000100000
%

_________________
Bob Rashkin
 
Thanks Bong for your answer...
So, it is the same by me!
But could you please tell me why the set c give this answer?
Normally, we should use puts to see any result?
Code:
%set c
0011000000001100000000100000
It is strange for me...!!
 
It's just a quirk of Tcl (assuming you're asking about the use of "set"). That is, what "set" returns is displayed on STDOUT. As for the actual binary, it is what it is, no?

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top