作为练习,我试图在c和x86-64 asm中实现多精度算术加法(程序的完整列表和objdump在帖子的末尾).
编辑:我添加了"addN4()"asm函数,删除"部分标志更新停止",现在"addN4()"是最快的.:)
EDIT2:添加了"addN5()"和"addN6()"c函数,用于计算正确的进位.(感谢Stephen Canon).
程序将两个数组中的数字添加到第三个数组中并生成进位值.多频谱数以小端格式存储.这是示例代码:
int carry = 0;
for (i = 0; i < n; i++) {
c[i] = a[i] + b[i] + carry;
carry = (c[i] < a[i]) || (c[i] < b[i]);
Run Code Online (Sandbox Code Playgroud)
我正在编写程序:
`gcc -g -O3 -Wall int.c -o int'
并运行代码:
'时间./int'
我得到以下执行时间:
addN1():
0.26s user 0.00s system 94% cpu 0.284 total
addN2():
0.42s user 0.00s system 96% cpu 0.441 total
addN3():
0.56s user 0.00s system 97% cpu 0.580 total
addN1() with -DCOUNT_CARRIES:
0.18s user 0.01s system …Run Code Online (Sandbox Code Playgroud) 我正在使用Razor MVC,我想显示"〜/ Content/uploads"文件夹中的图像.我提出了以下解决方案:
@foreach (FileInfo fileInfo in (new DirectoryInfo(Server.MapPath("~/Content/uploads"))
.GetFiles().Where(x => x.Extension == ".jpg"))) {
<img src="/@fileInfo
.FullName
.Substring(Server.MapPath("~/").Length)
.Replace("\\", "/")"
width="100">
}
Run Code Online (Sandbox Code Playgroud)
代码的问题是我正在获取完整的文件路径,我正在删除Server.MapPath()前缀.
如何简化此代码?