3789
|
1 ## Copyright (C) 2000 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 |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
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 |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
2268
|
19 |
3361
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} hex2dec (@var{s}) |
3789
|
22 ## Returns the integer corresponding to the hexadecimal number stored |
3361
|
23 ## in the string @var{s}. For example, |
3426
|
24 ## |
3361
|
25 ## @example |
|
26 ## hex2dec ("12B") |
|
27 ## @result{} 299 |
|
28 ## hex2dec ("12b") |
|
29 ## @result{} 299 |
|
30 ## @end example |
3789
|
31 ## |
|
32 ## If @var{s} is a string matrix, returns a column vector of converted |
|
33 ## numbers, one per row of @var{s}. Invalid rows evaluate to NaN. |
5642
|
34 ## @seealso{dec2hex, base2dec, dec2base, bin2dec, dec2bin} |
3361
|
35 ## @end deftypefn |
2268
|
36 |
3791
|
37 ## Author: Daniel Calvelo <dcalvelo@yahoo.com> |
3789
|
38 ## Adapted-by: Paul Kienzle <pkienzle@kienzle.powernet.co.uk> |
2314
|
39 |
2311
|
40 function d = hex2dec (h) |
2268
|
41 |
|
42 if (nargin != 1) |
6046
|
43 print_usage (); |
2268
|
44 else |
3789
|
45 d = base2dec (h, 16); |
2268
|
46 endif |
|
47 |
|
48 endfunction |