C ++转换:
我在此表单中收到硬件的信息:
SELECT
id,
min(diff)
FROM
(
SELECT
email.id,
a_email_contact.id_contact,
email.subject,
x.NAME,
x.OPTENTION_DATE,
email.SEND_DATE,
DATEDIFF(email.SEND_DATE, x.OPTENTION_DATE) as diff
FROM
classification_element y,
classification_version x ,
email,a_email_contact
where
x.id_project=y.id_project
and y.id_project=11
and y.id_company=3
and y.ID_VERSION=x.id
and email.SEND_DATE>x.OPTENTION_DATE
and a_email_contact.id_email=email.id
order by diff asc
) tmp
group by id
为x = 564
。
我已在int
中显示此信息:
float
为xFloat = 56.4
如果我float
我总是得到错误的结果:
x/10
代替56.5
。
这是 Round up problem 还是我的硬件可能无法提供正确的信息?
答案 0 :(得分:3)
请注意,在C ++中,默认小数为double
。
您也可以尝试使用这些:
int x=564;
float f=(float)x/10; //56.400002
float f1=x/10.0; //56.400002
float f11=x/10.0f; //56.400002
double d=(double)x/10; //56.400000
double d1=x/10.0; //56.400000
答案 1 :(得分:2)
您可以使用此类代码
function changeValue(){
if($(this).text() === 'div1'){
$(this).text('div2');
$('div2').hide();
$('div1').show();
}else{
$(this).text('div1');
$('div1').hide();
$('div2').show();
}
}