有没有人知道后缀" d + 0 "在下面的M1,M2和M4的作业中是什么意思,或者网上是否有任何资源或一本很可能找到这些信息的书?
subroutine plot( t, x, p, q, nga, nt, wron,
& ngq, gq, ngaq1, ngaq2, gaq, rwh, iwh )
implicit none
integer*4 nga, nt, ngq, ngaq1, ngaq2, iwh(*)
real*8 t, x(*), p(*), q(*), wron(nga,*),
& gq(ngq,*), gaq(ngaq1,ngaq2,*), rwh(*)
real*8 M1, M2, M3, M4, mr, mst, h3, Tc
integer*8 iflag
c DISCRETIZE1( Tc, rwh, iwh )
M1 = 0.1362d+0
M2 = 0.09806d+0
M3 = M1 + M2
M4 = 0.236d+0
mr = M1*x(1) + M2*x(2) + M3*x(3) …Run Code Online (Sandbox Code Playgroud) 我正在学习计算机算术.我使用的书(Patterson和Hennessey)列出了以下问题.
写mips代码以对64位数据进行双精度整数减法.假设第一个操作数在寄存器$ t4(hi)和$ t5(lo)中,第二个在$ t6(hi)和$ t7(lo)中.
我对答案的解决方案是
sub $t3, $t5, $t7 # Subtract lo parts of operands. t3 = t5 - t7
sltu $t2, $t5, $t7 # If the lo part of the 1st operand is less than the 2nd,
# it means a borrow must be made from the hi part
add $t6, $t6, $t2 # Simulate the borrow of the msb-of-low from lsb-of-high
sub $t2, $t4, $t6 # Subtract the hi's. t2 = t4 - t6
Run Code Online (Sandbox Code Playgroud)
然而,作者给出了针对该问题的解决方案如下
对于有符号的双精度整数, …
如何在java android中克服双乘法的精度问题?请注意我将字符串值转换为double值.
例如:当我乘以两个双倍值时:
double d1 = Double.valueOf("0.3").doubleValue() * Double.valueOf("3").doubleValue();
System.out.println("Result of multiplication : "+d1);
Run Code Online (Sandbox Code Playgroud)
我得到以下结果:0.8999999999999999
我得到的一些结果是.
0.6*3 = 1.7999999999999998;
0.2*0.2 = 0.04000000000000001;
等等
我希望得到以下结果,而不是上述结果.
0.3*3 = 0.9;
0.6*3 = 1.8;
0.2*0.2 = 0.04;
请记住,我不是要将它四舍五入到最接近的整数.
我在使用CUDA FFT库时遇到一些问题。
我将输入声明为cuDoubleComplex,但编译器返回以下错误:此类型与cufftComplex类型的参数不兼容。通过Internet搜索后,我发现文件cufft.h,其中有一行typedef cuComplex cufftComplex;。我的问题是,在cuComplex.h库中,很显然cuComplex具有单浮点精度(typedef cuFloatComplex cuComplex;),但是我想要双精度。
这可能吗?
特别是,我获得以下信息:
error: argument of type "cufftDoubleComplex *" is incompatible with parameter of type "cufftComplex *"
Run Code Online (Sandbox Code Playgroud)
在这一行:
cufftExecC2C(plan, data1, data2, CUFFT_FORWARD);
Run Code Online (Sandbox Code Playgroud) 我正在尝试将旧系统的一部分重写为C#程序.旧程序用C语言编写.两个程序都将blob文件读入一个字节数组,并用数据填充一个object/struct.
在原始C代码中,这是通过fread()完成的
fread(&myStruct, sizeof(MYSTRUCT), 1, data)
fseek(data, 256, 0)
fread(&nextStruct, sizeof(NEXTSTRUCT), 1, data)
Run Code Online (Sandbox Code Playgroud)
在C#中使用二进制阅读器
using(BinaryReader reader = new BinaryReader(stream)){
double1 = reader.ReadDouble();
double2 = reader.ReadDouble();
reader.BaseStream.Position = 256;
short1 = reader.ReadInt16();
... and so on ...
}
Run Code Online (Sandbox Code Playgroud)
在大多数情况下运行程序时,结果是相同的,但有时会出现小的偏差,对于某些blob,存在巨大的偏差.
在用洞察力调试C代码时,我发现从blob中提取后的值是不一样的.
示例
在C#中我得到212256608402. 688在C 212256608402. 68799为双值
在C#中我得到2.337在C 2.3370000000000001为短值
造成这种差异的原因是什么,是否可以解决?
在一些方法总结所有条目(高达一百万)并计算一些值后,这是否会导致5%或更多的错误?是否还有其他需要注意的陷阱,可能会导致错误的结果?
BigDecimal b = new BigDecimal(0.05);
System.out.println(b);
Run Code Online (Sandbox Code Playgroud)
输出:
0.05000000000000000277555756156289135105907917022705078125
Run Code Online (Sandbox Code Playgroud)
这要怎么处理呢?
这个查询有什么问题:我收到了以下错误
SQL错误:ORA-00905:缺少关键字00905. 00000 - "缺少关键字"
它在第4行说错误.请指教
CREATE TABLE ORDERS
(
ID INT NOT NULL,
ord_date DATE,
AMOUNT double,
CUSTOMER_ID INT references CUSTOMERS(ID),
PRIMARY KEY (ID)
);
Run Code Online (Sandbox Code Playgroud) 我看到了函数double frexp (double x, int* exp);,它将一个double分为尾数(m)和指数(e),幂为2(1.m * 2^e).是否有类似的函数以10的幂返回值?像是m * 10^e完美的东西.
我知道当我想检查双倍==双时我应该写:
bool AreSame(double a, double b)
{
return fabs(a - b) < EPSILON;
}
Run Code Online (Sandbox Code Playgroud)
但是当我想检查是否a > b或b > a?
为什么我的字典在我刚插入时说密钥不存在?是跟我的Equals方法还是双重比较有关?
这是代码:
// Test: I know the dictionary contains nCoord but its saying the key doesn't exist
Dictionary<UTMCoordinate, int> planes = new Dictionary<UTMCoordinate, int>();
UTMCoordinate nCoord = new UTMCoordinate(337394.136407966, 6263820.40182064, 0, 56, UTMCoordinate.Hemisphere.H_SOUTHERN);
planes[nCoord] = 1;
bool exists = planes.ContainsKey(nCoord); // always returns false
Run Code Online (Sandbox Code Playgroud)
我的实现UTMCoordinate如下:
public class UTMCoordinate
{
public enum Hemisphere {H_NOTHERN, H_SOUTHERN};
public const double DIF_TOLERANCE = 0.0005;
public double x { get; set; }
public double y { get; set; }
public double …Run Code Online (Sandbox Code Playgroud) double-precision ×10
c ×3
double ×3
c# ×2
java ×2
android ×1
bigdecimal ×1
comparison ×1
create-table ×1
cuda ×1
cufft ×1
dictionary ×1
fft ×1
fortran ×1
mips ×1
notation ×1
oracle ×1
signed ×1
sql ×1
unsigned ×1