w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

arithmetic.h
Go to the documentation of this file.
1 /* arithmetic.h
2 
3  Copyright 2009 Taco Hoekwater <taco@luatex.org>
4 
5  This file is part of LuaTeX.
6 
7  LuaTeX is free software; you can redistribute it and/or modify it under
8  the terms of the GNU General Public License as published by the Free
9  Software Foundation; either version 2 of the License, or (at your
10  option) any later version.
11 
12  LuaTeX is distributed in the hope that it will be useful, but WITHOUT
13  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15  License for more details.
16 
17  You should have received a copy of the GNU General Public License along
18  with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
19 
20 
21 #ifndef ARITHMETIC_H
22 # define ARITHMETIC_H
23 
24 /* |incr| and |decr| are in texmfmp.h */
25 
26  /* #define incr(A) (A)++ *//* increase a variable by unity */
27  /* #define decr(A) (A)-- *//* decrease a variable by unity */
28 
29 # define negate(A) (A)=-(A) /* change the sign of a variable */
30 
31 # undef half
32 extern int half(int x);
33 
34 /*
35 Fixed-point arithmetic is done on {\sl scaled integers\/} that are multiples
36 of $2^{-16}$. In other words, a binary point is assumed to be sixteen bit
37 positions from the right end of a binary computer word.
38 */
39 
40 # define unity 0200000 /* $2^{16}$, represents 1.00000 */
41 # define two 0400000 /* $2^{17}$, represents 2.00000 */
42 
43 typedef unsigned int nonnegative_integer; /* $0\L x<2^{31}$ */
44 
45 extern scaled round_decimals(int k);
46 extern void print_scaled(scaled s);
47 
48 extern boolean arith_error;
49 extern scaled tex_remainder;
50 
51 extern scaled mult_and_add(int n, scaled x, scaled y, scaled max_answer);
52 
53 # define nx_plus_y(A,B,C) mult_and_add((A),(B),(C),07777777777)
54 # define mult_integers(A,B) mult_and_add((A),(B),0,017777777777)
55 
56 extern scaled x_over_n(scaled x, int n);
57 extern scaled xn_over_d(scaled x, int n, int d);
58 
59 # define inf_bad 10000 /* infinitely bad value */
60 
61 extern halfword badness(scaled t, scaled s);
62 
63 # define set_glue_ratio_zero(A) (A)=0.0 /* store the representation of zero ratio */
64 # define set_glue_ratio_one(A) (A)=1.0 /* store the representation of unit ratio */
65 # define float_cast(A) (float)(A) /* convert from |glue_ratio| to type |real| */
66 # define unfloat(A) (glue_ratio)(A) /* convert from |real| to type |glue_ratio| */
67 # define float_constant(A) (float)A /* convert |integer| constant to |real| */
68 # define float_round round
69 
70 extern void initialize_arithmetic(void);
71 
72 extern scaled random_seed; /* the default random seed */
73 
74 extern void init_randoms(int seed);
75 extern int unif_rand(int x);
76 extern int norm_rand(void);
77 
78 extern int fix_int(int val, int min, int max);
79 
80 #endif
scaled round_decimals(int k)
Definition: arithmetic.c:68
int fix_int(int val, int min, int max)
Definition: arithmetic.c:812
scaled mult_and_add(int n, scaled x, scaled y, scaled max_answer)
Definition: arithmetic.c:166
void initialize_arithmetic(void)
Definition: arithmetic.c:558
boolean arith_error
Definition: arithmetic.c:152
scaled x_over_n(scaled x, int n)
Definition: arithmetic.c:188
void print_scaled(scaled s)
Definition: aptex-src.c:8377
scaled tex_remainder
Definition: arithmetic.c:156
void init_randoms(int seed)
Definition: arithmetic.c:730
scaled random_seed
Definition: arithmetic.c:358
int unif_rand(int x)
Definition: arithmetic.c:765
int norm_rand(void)
Definition: arithmetic.c:786
scaled xn_over_d(scaled x, int n, int d)
Definition: arithmetic.c:227
int half(int x)
Definition: arithmetic.c:52
halfword badness(scaled t, scaled s)
Definition: arithmetic.c:275
unsigned int nonnegative_integer
Definition: arithmetic.h:43
#define n
Definition: t4ht.c:1290
unsigned short halfword
Definition: dvips.h:68
#define s
Definition: afcover.h:80
#define d(n)
Definition: gpos-common.c:151
kerning y
Definition: ttdriver.c:212
float x
Definition: cordic.py:15
int k
Definition: otp-parser.c:70
#define min(a, b)
Definition: pbmplus.h:223
#define max(a, b)
Definition: pbmto4425.c:11
Definition: dvips.h:235
Definition: strexpr.c:21
long long scaled
Definition: vf_ng.c:93