相关问题 更多 >
编程相关推荐
- 使用SeleniumWebDriver(又称Selenium2.0)JAVA向下滚动鼠标
- java获取与消费者组kafka关联的主题列表
- java在现实生活中,您什么时候会使用堆栈而不是常规链表,或者使用常规队列而不是优先级队列?
- java实际参数列表和形式参数列表的长度不同(但两种长度都是2?)
- 默认情况下,Lucene(java框架)是否根据术语计算文档的tfidf和余弦相似性?
- java编辑XML样式表更改Android中的按钮
- java在Eclipse4中从处理程序更新视图
- java是节点列表、数组、列表还是其他什么?
- java Hibernate查询问题
- java Spark在并行化列表时引发ArrayIndexOutOfBoundsException
很快就搞定了,它符合你的需要吗?在
function GenerateAddends(n){ if(n == Math.round(n)){ return [Math.round(n/2),n-Math.round(n/2)]; }else{ var len = n.toString().split(".")[1].length return [ Math.round(n/2 * Math.pow(10,len)) / Math.pow(10,len), n - Math.round(n/2 * Math.pow(10,len)) / Math.pow(10,len) ] } } console.log(GenerateAddends(7)) console.log(GenerateAddends(7.2)) console.log(GenerateAddends(7.3)) console.log(GenerateAddends(7.25)) console.log(GenerateAddends(7.225))
;或者使用ECMAScript 2016:
我想把小数点和小数点的位数转换成同样的数字。在
下面是一个python示例: