Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
finesse
pykat
Commits
f8854255
Commit
f8854255
authored
Dec 01, 2013
by
Andreas Freise
Browse files
ading a converter from SI units to float. Rought but does the job.
parent
1745f726
Changes
1
Hide whitespace changes
Inline
Side-by-side
pykat/SIfloat.py
0 → 100644
View file @
f8854255
import
os
import
re
"""
class SIfloat(value):
def __init__(self, value):
self.__value = value
"""
#staticmethod
def
SIfloat
(
value
):
value
=
str
(
value
)
__prefix
=
{
'y'
:
1e-24
,
# yocto
'z'
:
1e-21
,
# zepto
'a'
:
1e-18
,
# atto
'f'
:
1e-15
,
# femto
'p'
:
1e-12
,
# pico
'n'
:
1e-9
,
# nano
'u'
:
1e-6
,
# micro
'm'
:
1e-3
,
# mili
'c'
:
1e-2
,
# centi
'd'
:
1e-1
,
# deci
'k'
:
1e3
,
# kilo
'M'
:
1e6
,
# mega
'G'
:
1e9
,
# giga
'T'
:
1e12
,
# tera
'P'
:
1e15
,
# peta
'E'
:
1e18
,
# exa
'Z'
:
1e21
,
# zetta
'Y'
:
1e24
,
# yotta
}
for
i
,
j
in
__prefix
.
iteritems
():
value
=
value
.
replace
(
i
,
str
(
j
))
return
float
(
value
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment