如果我有一个双(234.004223)等,我想将其舍入为C#中的x位有效数字.
到目前为止,我只能找到舍入到x小数位的方法,但如果数字中有任何0,则只会删除精度.
例如,0.086到一位小数位变为0.1,但我希望它保持在0.08.
我正在尝试安装libxml2,以便我可以设置python绑定并最终使用lxml.
但是,我无法在地球上工作,我应该解压缩文件.我没能成功谷歌.
我是否需要Cygwin/MinGW才能使安装成功?
目前,我将libxml2.tar.gz和libxslt.tar.gz中的文件放在Python文件夹中各自的目录中.因此,包含在包含的变量中的文件位于Python26\include\libxml2\libxml ...等等.
但是,当我运行easy_install lxml时,我收到以下输出:
Searching for lxml
Reading http://pypi.python.org/simple/lxml/
Reading http://codespeak.net/lxml
Best match: lxml 2.2.4
Downloading http://codespeak.net/lxml/lxml-2.2.4.tgz
Processing lxml-2.2.4.tgz
Running lxml-2.2.4\setup.py -q bdist_egg --dist-dir c:\users\rocco\appdata\local
\temp\easy_install-1xwbhy\lxml-2.2.4\egg-dist-tmp-9zwhe4
Building lxml version 2.2.4.
NOTE: Trying to build without Cython, pre-generated 'src/lxml/lxml.etree.c' need
s to be available.
ERROR: 'xslt-config' is not recognized as an internal or external command,
operable program or batch file.
** make sure the development packages of libxml2 and libxslt are installed **
Using build configuration of libxslt …Run Code Online (Sandbox Code Playgroud) 我有一个看起来像的对象树
Ball
/ \
LegalBall IllegalBall
Run Code Online (Sandbox Code Playgroud)
我有两种方法:
class o {
AddBall(LegalBall l)
AddBall(IllegalBall i)
}
Run Code Online (Sandbox Code Playgroud)
在另一个课程中,我想做以下事情:
o.AddBall(myBall);
Run Code Online (Sandbox Code Playgroud)
其中myBall是Ball类型.并根据子类型调用正确的方法.显然我不能这样做......论点不适用.
有谁知道我怎么能达到我想要的目的?或者如果有一个好的工作
谢谢
编辑:我正在尝试构建的应用程序是Cricket记分卡类型的东西.因此,根据击球的类型,各种其他元素应该改变.
我的初衷是能够指定球类型并从某种形式的UI中得分,然后从BallFactory创建一个合适的类型球,然后例如当我向团队得分发送一个无球时,它会将值添加到球队得分,但也增加了无球计数器的价值.但是当我向Batsmens Analysis提供相同的球来处理它时,它应该只能达到击球手总数的值-1.
我希望对我的初衷的解释不是太糟糕.
c# ×1
inheritance ×1
java ×1
libxml2 ×1
math ×1
methods ×1
overloading ×1
polymorphism ×1
python ×1
rounding ×1
windows ×1