Re: Conversion program decimal to hex and oct using assertions

2011-05-31 Thread Uri Guttman
> "SR" == Sayth Renshaw writes: >> Uri Guttman  --  u...@stemsystems.com     http://www.sysarch.com -- >> -  Perl Code Review , Architecture, Development, Training, Support -- >> -  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com - >> p

Re: Conversion program decimal to hex and oct using assertions

2011-05-31 Thread Sayth Renshaw
On Tue, May 31, 2011 at 3:45 PM, Uri Guttman wrote: >> "SR" == Sayth Renshaw 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 t

Re: Conversion program decimal to hex and oct using assertions

2011-05-30 Thread Uri Guttman
> "SR" == Sayth Renshaw 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 zer

Re: Conversion program decimal to hex and oct using assertions

2011-05-30 Thread Sayth Renshaw
On Tue, May 31, 2011 at 3:24 PM, Michael Greb wrote: > On Tue, May 31, 2011 at 02:27:53PM +1000, Sayth Renshaw wrote: >> This there formula $oct_perm_str = sprintf "%o", $perms; >> However it is not working for me. I have used my $oct = sprintf "%0", >> $number; > > You want '%o', the lower case

Re: Conversion program decimal to hex and oct using assertions

2011-05-30 Thread Michael Greb
On Tue, May 31, 2011 at 02:27:53PM +1000, Sayth Renshaw wrote: > This there formula $oct_perm_str = sprintf "%o", $perms; > However it is not working for me. I have used my $oct = sprintf "%0", $number; You want '%o', the lower case letter o for the sprintf format string, the sample code you showe

Re: Conversion program decimal to hex and oct using assertions

2011-05-30 Thread Brandon McCaig
On Tue, May 31, 2011 at 12:27 AM, Sayth Renshaw wrote: > Invalid conversion in sprintf: "%0" at hexToOctal.plx line 11, line 1. *snip* > my $oct = sprintf "%0", $number; I think that you meant %O (or maybe %o; but not %0). > my $hex = printf("0x%02x\n", $number); I think that you meant sprintf