>>>>> "SR" == Sayth Renshaw <flebber.c...@gmail.com> writes:

  SR> my $hex = sprintf("ox%o2x\n", $number);

why is the \n there? you just chomp it off. better to not put it in the
string to begin with.

also that leading char is the letter 'o' which is not the way octal
numbers are represented. they start with just a zero. also what is the
2x part for?

  SR> my $oct = sprintf "%o", $number;

  SR> When i turn on the assertion
  SR> use assertions ' $hex == $oct == $number ';

  SR> I am getting an error that an operator is required. Does that mean i
  SR> cannot compare a hex an octal and a decimal via equality in an
  SR> assertion?

that statement has several problems. == returns a boolean value so you
can't chain them like that. secondly, the sprintf strings you are
getting are not converted to the numbers as you think they are. strings
are only converted to decimal values by default. you need the hex and/or
oct functions to explicitly convert a hex/octal string to a decimal
value which can then be compared.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to