小编lon*_*kie的帖子

我需要将一个浮点数舍入到Java中的两个小数位

可能重复:
如何在Java中将数字舍入到n个小数位

我很难将浮点数舍入到小数点后两位.我已经尝试了一些我在这里看到的方法,包括只是使用Math.round(),但无论我做什么,我都会得到不寻常的数字.

我有一个我正在处理的浮动列表,列表中的第一个显示为1.2975118E7.什么是E7

当我使用Math.round(f)(f是浮动)时,我得到完全相同的数字.

我知道我做错了什么,我只是不确定是什么.

我只想要数字格式x.xx.第一个数字应该是1.30,等等.

java floating-point android

35
推荐指数
3
解决办法
11万
查看次数

有没有一种首选的方法来命名PHP中的变量?

我对PHP相当陌生,我想知道是否有一个标准约定来命名php变量。在命名变量时,我习惯使用驼峰式大小写,但在PHP示例中却看到很多下划线。

大多数人都使用PHP的标准命名约定吗?

$ buildingHeight或$ building_height

php variables

6
推荐指数
1
解决办法
7849
查看次数

使用replaceWith后,.click停止工作

好吧,我现在已经坚持了一段时间......

基本上我有两种方式我想要显示某个div.我计划使用replaceWith()替换#mainDiv与另一个版本的#mainDiv来创建一个函数.

这是功能:

function switchToChoice(){
            $('#myCanvas2').replaceWith('<div id="yesBox" width="150" height="90"><img id="yes" src="Yes-Button.png" width="110" height="55"></div><div id="noBox" width="150" height="90"><img id="no" class src="No-Button.png" width="110" height="55"></div>');

        }
Run Code Online (Sandbox Code Playgroud)

这可以工作并在调用时创建我想要的div框.div框中有两个图像,可以单击,但不执行单击操作.

这是在replaceWith之后无效的代码片段:

//If the user presses the Next button on the comment pages.
        $('#next').click(function() {
            $('#next').fadeTo(100, 0.25, function(){
                clearCanvas(ctx, c);
                wrapText(ctx, questionList[textPos], x, y-20, 275, 15);
                textPos++;
            });
            switchToChoice();
            $('#next').fadeTo(100, 1);
        });

        //If the user presses the Yes button on the question pages.
        $('#yes').click(function() {
            alert("boobs");
            $('#yes').fadeTo(100, 0.25, function(){
                clearCanvas(ctx, c);
                wrapText(ctx, questionList[textPos], x, y-20, 275, 15);
                textPos++; …
Run Code Online (Sandbox Code Playgroud)

html jquery html5 replacewith

2
推荐指数
1
解决办法
1700
查看次数

标签 统计

android ×1

floating-point ×1

html ×1

html5 ×1

java ×1

jquery ×1

php ×1

replacewith ×1

variables ×1