My Project
Loading...
Searching...
No Matches
gf_tabutil.cc
Go to the documentation of this file.
1/* emacs edit mode for this file is -*- C++ -*- */
2
3
4#include "config.h"
5
6
7#include "cf_assert.h"
8
9#include "cf_defs.h"
10#include "gf_tabutil.h"
11
12int gf_tab_numdigits62 ( int q )
13{
14 if ( q < 62 )
15 return 1;
16 else if ( q < 62*62 )
17 return 2;
18 else
19 return 3;
20}
21
22char conv62 ( int i )
23{
24 if ( i < 10 )
25 return '0' + char(i);
26 else if ( i < 36 )
27 return 'A' + char(i-10);
28 else
29 return 'a' + char(i-36);
30}
31
32void convert62 ( int i, int n, char * p )
33{
34 for ( int j = n-1; j >= 0; j-- ) {
35 p[j] = conv62( i % 62 );
36 i /= 62;
37 }
38}
39
40int convback62 ( char c )
41{
42 if ( c >= '0' && c <= '9' )
43 return int(c) - int('0');
44 else if ( c >= 'A' && c <= 'Z' )
45 return int(c) - int('A') + 10;
46 else
47 return int(c) - int('a') + 36;
48}
49
50int convertback62 ( char * p, int n )
51{
52 int r = 0;
53 for ( int j = 0; j < n; j++ )
54 r = r * 62 + convback62( p[j] );
55 return r;
56}
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4078
assertions for Factory
factory switches.
int j
Definition: facHensel.cc:110
int convback62(char c)
Definition: gf_tabutil.cc:40
int convertback62(char *p, int n)
Definition: gf_tabutil.cc:50
void convert62(int i, int n, char *p)
Definition: gf_tabutil.cc:32
int gf_tab_numdigits62(int q)
Definition: gf_tabutil.cc:12
char conv62(int i)
Definition: gf_tabutil.cc:22
utility functions to access GF Tables