当前位置: 首页 > 知识库问答 >
问题:

即使双变量时,(45/10)输出4[重复]

昝存
2023-03-14

当我写入(45/10)时,程序输出4。这是一个错误吗?

double newNum = (45 / 10); //output -> 4

共有1个答案

权黎昕
2023-03-14

没问题。10/4是两个整数的除法。试试看。

double newNum = (45 / 10.0);
 类似资料:
  • 常见的变量输出有如下情况: 1.在控制器中按如下方式赋值 $this->assign('hello','Hello ThinkCMF!'); return $this->fetch(); 在模板中: <div>{$hello}</div> 2.在控制器中赋值数组变量 $data = ['hello'=>'Hello ThinkCMF!','username'=>'老猫']; $this->as

  • 请参考:http://www.kancloud.cn/manual/thinkphp/1794

  • 变量输出 常见的变量输出有如下情况: 1.在控制器中按如下方式赋值 $this->assign('hello','Hello ThinkCMF!'); return $this->fetch(); 在模板中: <div>{$hello}</div> 2.在控制器中赋值数组变量 $data = ['hello'=>'Hello ThinkCMF!','username'=>'老猫']; $thi

  • 在模板中输出变量的方法很简单,例如,在控制器的方法中我们给模板变量赋值: $this->assign('name', 'thinkphp'); return $this->fetch(); 然后就可以在模板中使用: Hello,{$name}! 模板编译后的结果就是: Hello,<?php echo htmlentities($name);?>! 这样,运行的时候就会在模板中显示: Hello,

  • 首先需要在控制器中为模板变量赋值 $this->assign('username', $username); 在模板中可以使用{$username}输出变量$username

  • 2.5 输出变量 我们之前用了一些指令输出简单的值,你也可以使用相同的指令来输出一个变量的值。 int hour, minute; char colon; hour = 11; minute = 59; colon = ':'; cout << "The current time is"; cout << hour; cour << colon; cout << minute; cout <<