7017
|
1 ## Copyright (C) 1996, 1999, 2000, 2001, 2005, 2006, 2007 Daniel Calvelo |
2313
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
2313
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
2268
|
18 |
3361
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {} hex2dec (@var{s}) |
6666
|
21 ## Return the integer corresponding to the hexadecimal number stored |
3361
|
22 ## in the string @var{s}. For example, |
3426
|
23 ## |
3361
|
24 ## @example |
|
25 ## hex2dec ("12B") |
|
26 ## @result{} 299 |
|
27 ## hex2dec ("12b") |
|
28 ## @result{} 299 |
|
29 ## @end example |
3789
|
30 ## |
|
31 ## If @var{s} is a string matrix, returns a column vector of converted |
|
32 ## numbers, one per row of @var{s}. Invalid rows evaluate to NaN. |
5642
|
33 ## @seealso{dec2hex, base2dec, dec2base, bin2dec, dec2bin} |
3361
|
34 ## @end deftypefn |
2268
|
35 |
3791
|
36 ## Author: Daniel Calvelo <dcalvelo@yahoo.com> |
3789
|
37 ## Adapted-by: Paul Kienzle <pkienzle@kienzle.powernet.co.uk> |
2314
|
38 |
2311
|
39 function d = hex2dec (h) |
2268
|
40 |
|
41 if (nargin != 1) |
6046
|
42 print_usage (); |
2268
|
43 else |
3789
|
44 d = base2dec (h, 16); |
2268
|
45 endif |
|
46 |
|
47 endfunction |