Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


binary format - understanding output.

binary format - understanding output.

binary format - understanding output.

Hi All,
I am new to TCL and going through the binary format command. I am just trying to see how this command works. So I wrote few statements and directed the output to a file. Using hex edit I looked through the content but they are not as expected or may be I am not doing it right. Request you help me with my understanding. thanks .


set a [binary format B2 10 ]
puts $a
set a [binary format h4 abcd]
puts $a

set b "Hello World"
puts $b 


CODE -->

C2 80 0A C2  BA C3 9C 0A  48 65 6C 6C  6F 20 57 6F  72 6C 64 0A 
I understand that puts by default adds a newline, so 0A is the delimiter in my output.
my first statement in code i.e., binary format B2 10, as per my understanding, I thought it should give out x/80. But in my output I see an additional X/C2. Not sure why?
my third statement in code i.e., binary format h4 abcd, as per my understanding, I thought I should get x/ba x/cd, but I see again x/C2 x/BA x/C3 x/9C.

So I think I have got a complete wrong understanding from the manual. Any help is greatly appreciated.

Thank you

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close