1 .\" $NetBSD: prop_number.3,v 1.10 2011/01/20 10:44:42 wiz Exp $
3 .\" Copyright (c) 2006 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Jason R. Thorpe.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
35 .Nm prop_number_create_integer ,
36 .Nm prop_number_create_unsigned_integer ,
37 .Nm prop_number_copy ,
38 .Nm prop_number_size ,
39 .Nm prop_number_unsigned ,
40 .Nm prop_number_integer_value ,
41 .Nm prop_number_unsigned_integer_value ,
42 .Nm prop_number_equals ,
43 .Nm prop_number_equals_integer ,
44 .Nm prop_number_equals_unsigned_integer
45 .Nd numeric value property object
52 .Fn prop_number_create_integer "int64_t val"
54 .Fn prop_number_create_unsigned_integer "uint64_t val"
56 .Fn prop_number_copy "prop_number_t number"
59 .Fn prop_number_size "prop_number_t number"
61 .Fn prop_number_unsigned "prop_number_t number"
63 .Fn prop_number_integer_value "prop_number_t number"
65 .Fn prop_number_unsigned_integer_value "prop_number_t number"
68 .Fn prop_number_equals "prop_number_t num1" "prop_number_t num2"
70 .Fn prop_number_equals_integer "prop_number_t number" "int64_t val"
72 .Fn prop_number_equals_unsigned_integer "prop_number_t number" "uint64_t val"
76 family of functions operate on a numeric value property object type.
77 Values are either signed or unsigned, and promoted to a 64-bit type
78 .Pq int64_t or uint64_t , respectively .
80 It is possible to compare number objects that differ in sign.
81 Such comparisons first test to see if each object is within the valid
82 number range of the other:
85 Signed numbers that are greater than or equal to 0 can be compared to
88 Unsigned numbers that are less than or equal to the largest signed 64-bit
91 can be compared to signed numbers.
94 Number objects have a different externalized representation depending
98 Signed numbers are externalized in base-10
101 Unsigned numbers are externalized in base-16
105 When numbers are internalized, the sign of the resulting number object
106 .Pq and thus its valid range
107 is determined by a set of rules evaluated in the following order:
110 If the first character of the number is a
112 then the number is signed.
114 If the first two characters of the number are
116 then the number is unsigned.
118 If the number value fits into the range of a signed number then the
121 In all other cases, the number is unsigned.
123 .Bl -tag -width "xxxxx"
124 .It Fn prop_number_create_integer "int64_t val"
125 Create a numeric value object with the signed value
130 .It Fn prop_number_create_unsigned_integer "uint64_t val"
131 Create a numeric value object with the unsigned value
136 .It Fn prop_number_copy "prop_number_t number"
137 Copy a numeric value object.
138 If the supplied object isn't a numeric value,
141 .It Fn prop_number_size "prop_number_t number"
142 Returns 8, 16, 32, or 64, representing the number of bits required to
143 hold the value of the object.
144 If the supplied object isn't a numeric value,
147 .It Fn prop_number_unsigned "prop_number_t number"
150 if the numeric value object has an unsigned value.
151 .It Fn prop_number_integer_value "prop_number_t number"
152 Returns the signed integer value of the numeric value object.
153 If the supplied object isn't a numeric value, zero is returned.
155 it is not possible to distinguish between
156 .Dq not a prop_number_t
158 .Dq prop_number_t has a value of 0 .
159 .It Fn prop_number_unsigned_integer_value "prop_number_t number"
160 Returns the unsigned integer value of the numeric value object.
161 If the supplied object isn't a numeric value, zero is returned.
163 it is not possible to distinguish between
164 .Dq not a prop_number_t
166 .Dq prop_number_t has a value of 0 .
167 .It Fn prop_number_equals "prop_number_t num1" "prop_number_t num2"
170 if the two numeric value objects are equivalent.
171 If at least one of the supplied objects isn't a numeric value,
174 .It Fn prop_number_equals_integer "prop_number_t number" "int64_t val"
177 if the object's value is equivalent to the signed value
179 If the supplied object isn't a numerical value or if
185 .It Fn prop_number_equals_unsigned_integer "prop_number_t number" \
189 if the object's value is equivalent to the unsigned value
191 If the supplied object isn't a numerical value or if
202 .Xr prop_dictionary 3 ,
209 property container object library first appeared in