INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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!

*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.

Jobs

how to test binary format command?

how to test binary format command?

(OP)
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
 

RE: how to test binary format command?

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

RE: how to test binary format command?

(OP)
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...!!

RE: how to test binary format command?

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

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!

Resources

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