2 * c_pzasusb8 - print numereator as a string of USB8s
4 * Copyright (C) 1999-2004 Ernest Bowen
6 * Calc is open software; you can redistribute it and/or modify it under
7 * the terms of the version 2.1 of the GNU Lesser General Public License
8 * as published by the Free Software Foundation.
10 * Calc is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 * Public License for more details.
15 * A copy of version 2.1 of the GNU Lesser General Public License is
16 * distributed with calc under the filename COPYING-LGPL. You should have
17 * received a copy with calc; if not, write to Free Software Foundation, Inc.
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * @(#) $Revision: 30.1 $
21 * @(#) $Id: c_pzasusb8.c,v 30.1 2007/03/16 11:10:04 chongo Exp $
22 * @(#) $Source: /usr/local/src/bin/calc/custom/RCS/c_pzasusb8.c,v $
24 * Under source code control: 1999/10/06 03:12:25
25 * File existed as early as: 1999
27 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
35 #include "have_const.h"
40 #include "have_unused.h"
43 * c_pzasusb8 - print numereator as a string of USB8s
47 * vals[0] real number;
54 c_pzasusb8(char UNUSED
*name
, int UNUSED count
, VALUE
**vals
)
56 VALUE result
; /* what we will return */
57 ZVALUE z
; /* numerator of the value */
58 long half_cnt
; /* number of HALFs in the numerator */
59 USB8
*h
; /* octet pointer */
60 long half_len
; /* length of a half in octets */
67 result
.v_type
= V_NULL
;
68 if (vals
[0]->v_type
!= V_NUM
) {
69 math_error("Non-real argument for pzasusb8");
74 * look at the numerator
76 z
= vals
[0]->v_num
->num
;
77 half_len
= sizeof(HALF
);
84 for (i
=0; i
< half_cnt
; ++i
) {
86 for (j
=0; j
< half_len
; ++j
) {
87 printf("%02x", (int)(*h
++));