baseconvert 2.0.0__tar.gz → 2.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {baseconvert-2.0.0 → baseconvert-2.0.1}/LICENSE.txt +9 -9
- {baseconvert-2.0.0 → baseconvert-2.0.1}/MANIFEST.in +4 -4
- {baseconvert-2.0.0/baseconvert.egg-info → baseconvert-2.0.1}/PKG-INFO +164 -154
- {baseconvert-2.0.0 → baseconvert-2.0.1}/README.md +150 -145
- {baseconvert-2.0.0 → baseconvert-2.0.1}/README.rst +160 -151
- baseconvert-2.0.1/VERSION.txt +1 -0
- {baseconvert-2.0.0 → baseconvert-2.0.1}/baseconvert/ButtonRow.qml +107 -107
- {baseconvert-2.0.0 → baseconvert-2.0.1}/baseconvert/__init__.py +5 -5
- {baseconvert-2.0.0 → baseconvert-2.0.1}/baseconvert/__main__.py +51 -51
- {baseconvert-2.0.0 → baseconvert-2.0.1}/baseconvert/app.qml +246 -246
- {baseconvert-2.0.0 → baseconvert-2.0.1}/baseconvert/gui.py +54 -54
- {baseconvert-2.0.0 → baseconvert-2.0.1/baseconvert.egg-info}/PKG-INFO +164 -154
- {baseconvert-2.0.0 → baseconvert-2.0.1}/baseconvert.egg-info/requires.txt +2 -0
- {baseconvert-2.0.0 → baseconvert-2.0.1}/setup.py +47 -47
- baseconvert-2.0.0/VERSION.txt +0 -1
- {baseconvert-2.0.0 → baseconvert-2.0.1}/baseconvert/baseconvert.py +0 -0
- {baseconvert-2.0.0 → baseconvert-2.0.1}/baseconvert.egg-info/SOURCES.txt +0 -0
- {baseconvert-2.0.0 → baseconvert-2.0.1}/baseconvert.egg-info/dependency_links.txt +0 -0
- {baseconvert-2.0.0 → baseconvert-2.0.1}/baseconvert.egg-info/entry_points.txt +0 -0
- {baseconvert-2.0.0 → baseconvert-2.0.1}/baseconvert.egg-info/top_level.txt +0 -0
- {baseconvert-2.0.0 → baseconvert-2.0.1}/setup.cfg +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
Copyright (c) 2023 BreadMakesYouFull
|
|
3
|
-
Copyright (c) 2016 squdle
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright (c) 2023 BreadMakesYouFull
|
|
3
|
+
Copyright (c) 2016 squdle
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# Include the license file
|
|
2
|
-
include LICENSE.txt
|
|
3
|
-
include VERSION.txt
|
|
4
|
-
include README.md
|
|
1
|
+
# Include the license file
|
|
2
|
+
include LICENSE.txt
|
|
3
|
+
include VERSION.txt
|
|
4
|
+
include README.md
|
|
5
5
|
include README.rst
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: baseconvert
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.1
|
|
4
4
|
Summary: Convert numbers between bases.
|
|
5
5
|
Home-page: https://github.com/BreadMakesYouFull/baseconvert.git
|
|
6
6
|
Author: squdle, BreadMakesYouFull
|
|
@@ -14,156 +14,166 @@ Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
|
14
14
|
Classifier: Intended Audience :: Education
|
|
15
15
|
Classifier: License :: OSI Approved :: MIT License
|
|
16
16
|
License-File: LICENSE.txt
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
(positive integer) base
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
MIT License (MIT) Copyright (c)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
::
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
#
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
>>>
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
17
|
+
Provides-Extra: gui
|
|
18
|
+
Requires-Dist: pyside6; extra == "gui"
|
|
19
|
+
|
|
20
|
+
baseconvert
|
|
21
|
+
===========
|
|
22
|
+
|
|
23
|
+
Convert any rational number, from any (positive integer) base, to any
|
|
24
|
+
(positive integer) base. Output numbers as tuple or string.
|
|
25
|
+
|
|
26
|
+
- Any rational number
|
|
27
|
+
- Arbitrary precision
|
|
28
|
+
- Fractions
|
|
29
|
+
- Recurring/repeating fractional digits.
|
|
30
|
+
- Input numbers as tuple or string or number.
|
|
31
|
+
- Output numbers as tuple or string.
|
|
32
|
+
|
|
33
|
+
MIT License (MIT) Copyright (c) 2024 BreadMakesYouFull
|
|
34
|
+
MIT License (MIT) Copyright (c) 2016 squdle
|
|
35
|
+
|
|
36
|
+
`github <https://github.com/BreadMakesYouFull/baseconvert>`__
|
|
37
|
+
|
|
38
|
+
Requires
|
|
39
|
+
--------
|
|
40
|
+
|
|
41
|
+
- Python 3
|
|
42
|
+
|
|
43
|
+
Install / Uninstall
|
|
44
|
+
-------------------
|
|
45
|
+
|
|
46
|
+
Install:
|
|
47
|
+
|
|
48
|
+
::
|
|
49
|
+
|
|
50
|
+
pip install baseconvert
|
|
51
|
+
|
|
52
|
+
Optionally install GUI frontend and launch:
|
|
53
|
+
|
|
54
|
+
::
|
|
55
|
+
|
|
56
|
+
# Install with pyside6
|
|
57
|
+
pip install baseconvert[gui]
|
|
58
|
+
# Run GUI frontend
|
|
59
|
+
baseconvert
|
|
60
|
+
|
|
61
|
+
Uninstall:
|
|
62
|
+
|
|
63
|
+
::
|
|
64
|
+
|
|
65
|
+
pip uninstall baseconvert
|
|
66
|
+
|
|
67
|
+
Quickstart
|
|
68
|
+
----------
|
|
69
|
+
|
|
70
|
+
::
|
|
71
|
+
|
|
72
|
+
# base(number, input_base, output_base)
|
|
73
|
+
|
|
74
|
+
>>> base((15, 15, 0, ".", 8), 16, 10)
|
|
75
|
+
(4, 0, 8, 0, '.', 5)
|
|
76
|
+
|
|
77
|
+
>>> base("FF0.8", 16, 10, string=True)
|
|
78
|
+
'4080.5'
|
|
79
|
+
|
|
80
|
+
>>> base("4080.5", 10, 16, string=True)
|
|
81
|
+
'FF0.8'
|
|
82
|
+
|
|
83
|
+
Or from command line
|
|
84
|
+
|
|
85
|
+
::
|
|
86
|
+
|
|
87
|
+
$ echo 4080.5 | python -m baseconvert -i 10 -o 16
|
|
88
|
+
FF0.8
|
|
89
|
+
|
|
90
|
+
$ python -m baseconvert -n 4080.5 -i 10 -o 16
|
|
91
|
+
FF0.8
|
|
92
|
+
|
|
93
|
+
Tuple representation
|
|
94
|
+
--------------------
|
|
95
|
+
|
|
96
|
+
Numbers are represented as a sequence of digits. Each digit is a base-10
|
|
97
|
+
integer value. The radix point, which separates the integer and
|
|
98
|
+
fractional parts, is denoted by a string period.
|
|
99
|
+
|
|
100
|
+
::
|
|
101
|
+
|
|
102
|
+
(int, int, int, ... , '.', ... , int, int, int)
|
|
103
|
+
( integer part , '.', fractional part )
|
|
104
|
+
|
|
105
|
+
String representation
|
|
106
|
+
---------------------
|
|
107
|
+
|
|
108
|
+
String digits (after z the values are in ascending Unicode):
|
|
109
|
+
|
|
110
|
+
::
|
|
111
|
+
|
|
112
|
+
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
|
113
|
+
|
|
114
|
+
| Value | Representation |
|
|
115
|
+
|---------|----------------|
|
|
116
|
+
| 0 - 9 | 0 - 9 |
|
|
117
|
+
| 10 - 53 | A - Z |
|
|
118
|
+
| 36 - 61 | a - z |
|
|
119
|
+
| 62 + | unicode 123 + |
|
|
120
|
+
|
|
121
|
+
For bases higher than 61 it's recommended to use tuple representation.
|
|
122
|
+
|
|
123
|
+
Examples
|
|
124
|
+
--------
|
|
125
|
+
|
|
126
|
+
::
|
|
127
|
+
|
|
128
|
+
# base(number, input_base, output_base)
|
|
129
|
+
>>> n = (15,15,".",0,8)
|
|
130
|
+
>>> base(n, 16, 10)
|
|
131
|
+
(2, 5, 5, '.', 0, 3, 1, 2, 5)
|
|
132
|
+
>>> base(n, 16, 10, string=True)
|
|
133
|
+
'255.03125'
|
|
134
|
+
|
|
135
|
+
>>> base("FF.08", 16, 10) == base((15,15,".",0,8), 16, 10)
|
|
136
|
+
True
|
|
137
|
+
|
|
138
|
+
# A callable BaseConverter object can also be created.
|
|
139
|
+
# This is useful for when several numbers need to be converted.
|
|
140
|
+
|
|
141
|
+
>>> b = BaseConverter(input_base=16, output_base=8)
|
|
142
|
+
>>> b("FF")
|
|
143
|
+
(3, 7, 7)
|
|
144
|
+
>>> b((15, 15))
|
|
145
|
+
(3, 7, 7)
|
|
146
|
+
>>> b("FF") == b((15,15))
|
|
147
|
+
True
|
|
148
|
+
|
|
149
|
+
>>> base(0.1, 3, 10, string=True)
|
|
150
|
+
'0.[3]'
|
|
151
|
+
|
|
152
|
+
Recurring digits
|
|
153
|
+
~~~~~~~~~~~~~~~~
|
|
154
|
+
|
|
155
|
+
Recurring digits at the end of a fractional part will be enclosed by "["
|
|
156
|
+
and "]" in both string and tuple representation. This behavior can be
|
|
157
|
+
turned off by setting the recurring argument of base or BaseConverter
|
|
158
|
+
object to False.
|
|
159
|
+
|
|
160
|
+
::
|
|
161
|
+
|
|
162
|
+
>>> base("0.1", 3, 10, string=True)
|
|
163
|
+
'0.[3]'
|
|
164
|
+
>>> base("0.1", 3, 10, string=True, recurring=False)
|
|
165
|
+
'0.3333333333'
|
|
166
|
+
|
|
167
|
+
Max fractional depth
|
|
168
|
+
~~~~~~~~~~~~~~~~~~~~
|
|
169
|
+
|
|
170
|
+
Integer parts are always of arbitrary size. Fractional depth (number of
|
|
171
|
+
digits) can must be specified by setting the max\_depth argument of base
|
|
172
|
+
or a BaseConverter object (default 10).
|
|
173
|
+
|
|
174
|
+
::
|
|
175
|
+
|
|
176
|
+
>>> base("0.2", 10, 8)
|
|
177
|
+
(0, '.', 1, 4, 6, 3, 1, 4, 6, 3, 1, 4)
|
|
178
|
+
>>> base("0.2", 10, 8, max_depth=1)
|
|
179
|
+
(0, '.', 1)
|
|
@@ -1,145 +1,150 @@
|
|
|
1
|
-
baseconvert
|
|
2
|
-
===========
|
|
3
|
-
|
|
4
|
-
Convert rational numbers between bases.
|
|
5
|
-
|
|
6
|
-

|
|
7
|
-
|
|
8
|
-
[https://github.com/BreadMakesYouFull/baseconvert](https://github.com/BreadMakesYouFull/baseconvert)
|
|
9
|
-
|
|
10
|
-
## Install
|
|
11
|
-
|
|
12
|
-
Requires:
|
|
13
|
-
* python 3
|
|
14
|
-
* pyside6 for GUI
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
# Install from pypi via pip
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
>>> base(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
>>> b
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
>>>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
1
|
+
baseconvert
|
|
2
|
+
===========
|
|
3
|
+
|
|
4
|
+
Convert rational numbers between bases.
|
|
5
|
+
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
[https://github.com/BreadMakesYouFull/baseconvert](https://github.com/BreadMakesYouFull/baseconvert)
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
Requires:
|
|
13
|
+
* python 3
|
|
14
|
+
* pyside6 for GUI
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
# Install from pypi via pip
|
|
18
|
+
# Without GUI:
|
|
19
|
+
pip install baseconvert
|
|
20
|
+
# With GUI:
|
|
21
|
+
pip install baseconvert[gui]
|
|
22
|
+
|
|
23
|
+
# ...or install from source
|
|
24
|
+
git clone https://github.com/BreadMakesYouFull/baseconvert
|
|
25
|
+
python -m venv venv
|
|
26
|
+
# With GUI
|
|
27
|
+
./venv/bin/pip install .[gui]
|
|
28
|
+
# Without GUI
|
|
29
|
+
./venv/bin/pip install .
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Run UI
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
baseconvert
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Python Library
|
|
40
|
+
|
|
41
|
+
Convert any rational number, from any positive integer base, to any positive integer base.
|
|
42
|
+
|
|
43
|
+
Output numbers as tuple or string.
|
|
44
|
+
|
|
45
|
+
- Any rational number
|
|
46
|
+
- Arbitrary precision
|
|
47
|
+
- Fractions
|
|
48
|
+
- Recurring/repeating fractional digits.
|
|
49
|
+
- Input numbers as tuple or string or number.
|
|
50
|
+
- Output numbers as tuple or string.
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
# base(number, input_base, output_base)
|
|
54
|
+
>>> base((15, 15, 0, ".", 8), 16, 10)
|
|
55
|
+
(4, 0, 8, 0, '.', 5)
|
|
56
|
+
|
|
57
|
+
>>> base("FF0.8", 16, 10, string=True)
|
|
58
|
+
'4080.5'
|
|
59
|
+
|
|
60
|
+
>>> base("4080.5", 10, 16, string=True)
|
|
61
|
+
'FF0.8'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Or from command line
|
|
65
|
+
|
|
66
|
+
$ echo 4080.5 | python -m baseconvert -i 10 -o 16
|
|
67
|
+
FF0.8
|
|
68
|
+
|
|
69
|
+
$ python -m baseconvert -n 4080.5 -i 10 -o 16
|
|
70
|
+
FF0.8
|
|
71
|
+
|
|
72
|
+
### Tuple representation
|
|
73
|
+
|
|
74
|
+
Numbers are represented as a sequence of digits.
|
|
75
|
+
Each digit is a base-10 integer value.
|
|
76
|
+
The radix point, which separates the integer and fractional parts,
|
|
77
|
+
is denoted by a string period.
|
|
78
|
+
|
|
79
|
+
(int, int, int, ... , '.', ... , int, int, int)
|
|
80
|
+
( integer part , '.', fractional part )
|
|
81
|
+
|
|
82
|
+
### String representation
|
|
83
|
+
|
|
84
|
+
String digits (after z the values are in ascending Unicode):
|
|
85
|
+
|
|
86
|
+
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
|
87
|
+
|
|
88
|
+
| Value | Representation |
|
|
89
|
+
|---------|----------------|
|
|
90
|
+
| 0 - 9 | 0 - 9 |
|
|
91
|
+
| 10 - 35 | A - Z |
|
|
92
|
+
| 36 - 61 | a - z |
|
|
93
|
+
| 62 + | unicode 123 + |
|
|
94
|
+
|
|
95
|
+
For higher bases it's recommended to use tuple representation.
|
|
96
|
+
|
|
97
|
+
### Examples
|
|
98
|
+
|
|
99
|
+
# base(number, input_base, output_base)
|
|
100
|
+
>>> n = (15,15,".",0,8)
|
|
101
|
+
>>> base(n, 16, 10)
|
|
102
|
+
(2, 5, 5, '.', 0, 3, 1, 2, 5)
|
|
103
|
+
>>> base(n, 16, 10, string=True)
|
|
104
|
+
'255.03125'
|
|
105
|
+
|
|
106
|
+
>>> base("FF.08", 16, 10) == base((15,15,".",0,8), 16, 10)
|
|
107
|
+
True
|
|
108
|
+
|
|
109
|
+
# A callable BaseConverter object can also be created.
|
|
110
|
+
# This is useful for when several numbers need to be converted.
|
|
111
|
+
|
|
112
|
+
>>> b = BaseConverter(input_base=16, output_base=8)
|
|
113
|
+
>>> b("FF")
|
|
114
|
+
(3, 7, 7)
|
|
115
|
+
>>> b((15, 15))
|
|
116
|
+
(3, 7, 7)
|
|
117
|
+
>>> b("FF") == b((15,15))
|
|
118
|
+
True
|
|
119
|
+
|
|
120
|
+
>>> base(0.1, 3, 10, string=True)
|
|
121
|
+
'0.[3]'
|
|
122
|
+
|
|
123
|
+
### Recurring digits
|
|
124
|
+
|
|
125
|
+
Recurring digits at the end of a fractional part will be enclosed by
|
|
126
|
+
"[" and "]" in both string and tuple representation.
|
|
127
|
+
This behavior can be turned off by setting the recurring argument of base or
|
|
128
|
+
BaseConverter object to False.
|
|
129
|
+
|
|
130
|
+
>>> base("0.1", 3, 10, string=True)
|
|
131
|
+
'0.[3]'
|
|
132
|
+
>>> base("0.1", 3, 10, string=True, recurring=False)
|
|
133
|
+
'0.3333333333'
|
|
134
|
+
|
|
135
|
+
### Max fractional depth
|
|
136
|
+
|
|
137
|
+
Integer parts are always of arbitrary size.
|
|
138
|
+
Fractional depth (number of digits) can must be specified by setting the
|
|
139
|
+
max_depth argument of base or a BaseConverter object (default 10).
|
|
140
|
+
|
|
141
|
+
>>> base("0.2", 10, 8)
|
|
142
|
+
(0, '.', 1, 4, 6, 3, 1, 4, 6, 3, 1, 4)
|
|
143
|
+
>>> base("0.2", 10, 8, max_depth=1)
|
|
144
|
+
(0, '.', 1)
|
|
145
|
+
|
|
146
|
+
### Exact...ish
|
|
147
|
+
|
|
148
|
+
You can also set ``max_depth=0`` or use the flag ``exact=True``, which are equivalent. These "Exact" results will be only precise only up to the value of ``baseconvert.baseconvert.MAX_DEPTH`` which you may also override, but is limited by default for speed.
|
|
149
|
+
|
|
150
|
+
This is only relevant for fractional numbers, integer values should always be accurate.
|