小编zel*_*ell的帖子

Java:创建一个以字母为索引的数组

是否有可能在Java中创建一个由字母字符('a'到'z')而不是整数索引的数组?

使用这样的数组"a",我想以这种方式使用,例如

print (a['a']);
Run Code Online (Sandbox Code Playgroud)

java arrays indexing

5
推荐指数
2
解决办法
2万
查看次数

使用git clone时错误的数字配置值

每当我使用时git clone,我都会收到此信息.我该怎么办?

fatal: bad numeric config value '5242880000' for 'http.postbuffer': out of range
Run Code Online (Sandbox Code Playgroud)

git macos

5
推荐指数
1
解决办法
1885
查看次数

用于增强中间浮点计算精度的编译器标志

gcc/clang中是否有一个标志指定中间浮点计算的精度?

假设我有一个C代码

double x = 3.1415926;
double y = 1.414;
double z = x * y;
Run Code Online (Sandbox Code Playgroud)

是否有编译器标志允许以用户机器的最高精度计算'x*y',例如,long-double(64位尾数),然后截断为double(53位尾数,声明变量类型的精度)?

仅供参考,我在64位计算机上使用Ubuntu 14.04.

c c++ floating-point precision compilation

5
推荐指数
1
解决办法
1008
查看次数

为什么 F# 交互式控制台不认为“assert (2=3)”是错误的?

我将此行发送到 Visual Studio 中的 F# 交互式控制台

assert (2=3)
Run Code Online (Sandbox Code Playgroud)

出乎我的意料,控制台没有报错,但是

 

val it : unit = ()
Run Code Online (Sandbox Code Playgroud)

同样,如果我跑

printf ("hello!")

assert (2=3)

printf ("hello2")
Run Code Online (Sandbox Code Playgroud)

在 REPL 上,我收到了“hellohello2”而没有任何错误消息。

我怎样才能让 F# 交互告诉我 2=3 是错误的?

f#

5
推荐指数
1
解决办法
112
查看次数

了解由未定义行为清理程序 (UBSan) 触发的运行时错误

当启用未定义的消毒剂时,我在 GNU 科学库 (GSL) 中发现了一个运行时错误:

deque.c:58:11: runtime error: member access within misaligned address 0x0000024010f4 for type 'struct deque', which requires 8 byte alignment
0x0000024010f4: note: pointer points here
  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
              ^ 
deque.c:59:11: runtime error: member access within misaligned address 0x0000024010f4 for type 'struct deque', which requires 8 byte alignment
0x0000024010f4: …
Run Code Online (Sandbox Code Playgroud)

security sanitizer gsl ubsan

5
推荐指数
1
解决办法
173
查看次数

我们可以查看部分推断的输入信息.来自Ocaml toplevel /编译器的程序无法编译?

我想知道,在Ocaml中,是否有部分输入信息.可以通过toplevel/compiler的一些现有功能绘制,对于不编译的程序?让我解释.

在Ocaml中,众所周知,推断类型可以通过-annot文件检索.但是,有时我们有一段代码由于某些输入错误而无法编译.它会将错误导出到此模式的顶层

"This expression has type A, but was expected type B" 
Run Code Online (Sandbox Code Playgroud)

一个人为的例子

# let x =  
  let y = 5  in
  not y;;
    Characters 32-33:
    not y;;
        ^
Error: This expression has type int 
       but an expression was expected of type bool
Run Code Online (Sandbox Code Playgroud)

这段代码的程序员应该很好地理解这条消息的第二部分,即"y是期望类型bool",因为"not y"部分.但是,她/他可能有一些困难要理解此错误消息的第一部分:如何推断这个"y"具有类型"int"?因此,在引发类型冲突之前,有一组部分推断类型会很有趣.对于上面的例子,人们希望解释器告诉第一个"y"(来自"let y = 5")是int类型,通过它我将知道第二个"y"(来自"not y")的原因)被推测为int类型.

你能告诉我一些ocaml解释器/编译器是否已经提供了所描述的功能吗?

一般来说,我的问题是:ocaml toplevel或其解释器可以产生用户可以检索的部分推断类型,以便更有效地找到其输入错误的来源吗?

由于部分推断类型注释的非唯一性,此问题可能没有意义.但是,示例示例应该表明至少在某些情况下,某些部分推断类型具有其用法.

谢谢你的想法.

debugging ocaml typing partial

4
推荐指数
1
解决办法
123
查看次数

浮点运算中 - ( - x)= x是否正确?

假设x是一个浮点数,我想知道是否- ( - x)等于x一般?

让我们忽略诸如x = max_floating_point_number/min_floating_number之类的极端情况.

floating-point ieee-754

4
推荐指数
1
解决办法
90
查看次数

如何知道我的程序在运行时调用哪个'sin'函数?

我使用的是不同版本的libm.a. 我正在玩的是fdlibm的libm.a(来自Sun).

问题是我觉得我的程序没有调用fdlibm的libm.a中的函数,而是调用系统的glibc的libm.a中的函数.

#include "fdlibm.h"
int main(){
  double x = sin(3);
}
Run Code Online (Sandbox Code Playgroud)

该程序是编译的C++程序(因为它必须与其他c ++程序链接):

g ++ prog.cpp libm.a

其中libm.a是fdlibm的.(来自Sun,http://www.netlib.org/fdlibm/readme)

问题1

我怎么知道sin在运行时实际调用了什么?我听说过objdump,gdb等各种工具......哪一个可以用于我的案例以及如何使用?

问题2

如何强制使用fdlibm的libm.a?

谢谢.

c++ static-linking

4
推荐指数
1
解决办法
110
查看次数

在Python中,我如何翻译*(1+(int*)&x)?

这个问题是一个跟进这一个.在Sun的数学库(在C中),表达式

*(1+(int*)&x)
Run Code Online (Sandbox Code Playgroud)

用于检索浮点数的高位字x.这里,OS假定为64位,具有little-endian表示.

我在想如何将上面的C表达式翻译成Python?这里的困难是如何翻译表达式中的'&'和'*'.顺便说一句,也许Python有一些内置函数可以检索浮点数的高位字?

c python floating-point bit-representation

4
推荐指数
1
解决办法
160
查看次数

LLVM 中的毒值和未定义值

LLVM 引入了“毒值”的概念,我一直都不敢肯定理解。例如,对于语句

%add = add nsw i32 %x, 1
Run Code Online (Sandbox Code Playgroud)

如果%x+1严格大于最大的 i32 整数,则将任意值分配给 %add。声称上面的语句,即 %add = add nsw i32 %x, 1,可以在语义上描述为:

if (%x+1) overflows then %add = undef else %add = add i32 %x,1
Run Code Online (Sandbox Code Playgroud)

?

compiler-errors undef llvm compiler-optimization

4
推荐指数
1
解决办法
2304
查看次数