Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for dec2hex.pl

(view source code of dec2hex.pl as plain text)

  1. #! perl
  2.  
  3. if ( ( index( $ARGV[0], "?" ) > -1 ) || ( $ARGV[0] == null ) || ( $ARGV[1] != null ) ) {
  4. 	print "\nDec2Hex.pl,  Version 1.00\n",
  5. 	      "Convert specified decimal number to 8 digit hexadecimal\n\n",
  6. 	      "Usage:  DEC2HEX.PL  number\n\n",
  7. 	      "Where:  \"number\" is any decimal number ranging from ",
  8. 	      "0..2147483647 (0x7FFFFFFF)\n\n",
  9. 	      "Written by Rob van der Woude\n",
  10. 	      "http://www.robvanderwoude.com\n";
  11. }
  12. else {
  13. 	$number = $ARGV[0];
  14. 	$result = sprintf( "%08X", $number );
  15. 	print "\n$ARGV[0] = 0x$result\n";
  16. }
  17.  

page last uploaded: 2017-04-06, 13:33