我说,我正在划分一个数字
x=2;
y=1/3;
z=x*y;
Run Code Online (Sandbox Code Playgroud)
我希望z为0.66666666666667小数点后的14个数字,y为相同的数字.现在,当我这样做时,我0.6667只得到.如何将答案扩展到精确的14位精度?
您好我有一个矩阵,其中包含浮点数和int数字我想以某种方式将其打印到文件中,如果它不是整数打印浮动后舍入为1的数值.以下是我的代码
use Scalar::Util::Numeric qw(isint);
for ( $i = 0 ; $i < $#matrix ; $i++ ) {
for ( $j = 0 ; $j < $#{ $matrix[0] } ; $j++ ) {
if (not isint $matrix[$i][$j] ) {
printf MYFILE ("%.1f",$matrix[$i][$j]{score});
}
else {
print MYFILE $matrix[$i][$j]{score}.' ';
}
}
print MYFILE "\n";
}
Run Code Online (Sandbox Code Playgroud)
问题是这个代码输出将所有内容都写为float,即使它是一个整数.怎么解决?
#include<stdio.h>
#include<math.h>
int main()
{
printf("%f",3/2);
printf(" %d",3/2);
printf(" %d",3<<2);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是我的代码,我期望获得1.50000 1 12
但我收到了2.168831 1 12
作为我的输出.
当鼠标悬停在某个类的元素A上时,应出现另一个包含链接的浮动divB。鼠标离开A和B后,B应该消失。
我该如何使用jQuery? jsFiddle
var container = $('#container');
var area = $('.area'); // this is A
var position = area.offset();
var floating = $("<div />", {
css : { "position" : "absolute",
"top" : position.top - 30,
"left" : position.left + 20,
"border" : "1px solid #000",
"padding" : "5px",
"display" : "none",
"z-index" : "100",
"background-color" : "#F00"
}
})
.text('Hello World'); // this is B
container.css('position', 'relative');
container.append(floating);
function show() {
floating.show();
}
function hide() {
floating.hide();
}
area.on('mouseenter', …Run Code Online (Sandbox Code Playgroud) 我正在从单个scanf输出中读取多个浮点数.
#include<stdio.h>
#include<math.h>
int main()
{ float a,b,c;
float d,rot1,rot2;
scanf("%f%f%f ", &a, &b, &c);
d = sqrt(b*b - 4*a*c);
rot1 = (-b-d)/(2*a);
rot2 = (-b+d)/(2*a);
printf("%f %f", rot1, rot2);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它需要4个输入; 但是,我想只为变量a,b和c的地址提供3个输入.我不知道从哪个变量获取额外的输入.当我编写用于获取2变量输入的代码时,它需要3个输入.
$f = sprintf ("%.1f",$per);
echo "You hit".$f."
Run Code Online (Sandbox Code Playgroud)
通过这段代码我可以在浮点后只显示一位数.但是当我的结果是100%时,它显示100.0%.我想100%显示.我怎么能这样做????
我第一次在MATLAB中使用了一个函数.函数体正常工作.但是当从程序中调用它时会产生错误.
功能是:
function f = adjust(value)
if value < 0
s = -1;
value = -value;
else
s = 1;
end
b = floor(value);
value = value-b;
value = s*value;
f = sprintf('%.14f', value);
Run Code Online (Sandbox Code Playgroud)
主要计划是
x(1) = 0.3;
y(1) = -0.4;
a = 36;
for n = 2:16
temp = a*(y(n-1)-x(n-1));
x(n) = adjust(temp);
end
Run Code Online (Sandbox Code Playgroud)
我想要精确生成许多值1e-14.
当我运行程序时,我得到错误
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> …Run Code Online (Sandbox Code Playgroud) 为什么以下生成TypeError: 'float' object not callable?
sum([-450.0,950.0])
当我'-0'在float中转换字符串时,它返回float类型-0
例
$x = '-0';
$y = (float)$x;
Run Code Online (Sandbox Code Playgroud)
result => float -0
为什么-0是浮号?
使用 php (preg_match) 验证变量是否为浮点型。
一直在网上搜索,但仍然没有找到我需要的。请建议。
我的要求:
有效
(仅限数字和一个点)
0.1(任何以 0 开头的内容,后面必须跟一个点,然后是数字)
1.1234567890(最多 10 位小数)
无效
空白/空格
0
0.
0.0
00.0
0.0.0
01
整数
+0.1(无加号)
-0.1(无减号)
.1
01.1
1.
0.1e38(无指数)
解决方案:
/^(?=.*[1-9])(?!0\d)([0-9]{1,10})(\.[0-9]{1,10})$/
Run Code Online (Sandbox Code Playgroud)