小编msk*_*her的帖子

OCaml:List.fold_left如何工作?

我试图找到一个浮动列表的平均值.

let avg l =
    List.fold_left ( +. ) 0 l /. List.length l;;
Run Code Online (Sandbox Code Playgroud)

List.fold_left如何工作?(将第一个参数应用于列表(第三个arg)...但是第二个参数是什么?)

Toplevel返回此错误:

Characters 43-44:
        List.fold_left ( +. ) 0 l /. List.length l;;
                             ^
Error: This expression has type int but is here used with type float
Run Code Online (Sandbox Code Playgroud)

迭代OCaml中的列表的首选方法是什么?

floating-point ocaml list

3
推荐指数
2
解决办法
6693
查看次数

为什么PHP使用Zend_Amf将数字16转换为float(6.1026988574311E_320)

Zend_Amf规范声明从flash返回的Number类型将映射到PHP中的float.精细.但是为什么16号作为6.1026988574311E_320返回?在OS X上运行的PHP版本为5.2.9.

我已经尝试在PHP中强制转换为整数(上面的值被舍入为0),并且还使用int(16)从Actionscript中强制转换 - 后者通过NULL来实现.如何确保Flash通过AMF返回一个整数并且PHP可以处理它?

php floating-point integer

3
推荐指数
1
解决办法
361
查看次数

在MySQL中浮动不正确

我正在进入'35444650.00'作为我的MySQL的浮动,它一直重新格式化为35444648.00,任何帮助欢迎...

php mysql floating-point precision

3
推荐指数
1
解决办法
3340
查看次数

水平居中浮箱

我想显示一些浮动框(包含缩略图的div),缩略图的数量取决于当前的页面宽度.例如:

<div class="container">
  <div class="box1" style="float:left;width:120px;height:120px;margin-right:10px;">Thumbnail image here</div>
  <div class="box2" style="float:left;width:120px;height:120px;margin-right:10px;">Thumbnail image here</div>
  <div class="box3" style="float:left;width:120px;height:120px;margin-right:10px;">Thumbnail image here</div>
  <div class="box4" style="float:left;width:120px;height:120px;margin-right:10px;">Thumbnail image here</div>
    .......... ETC
</div>
Run Code Online (Sandbox Code Playgroud)

问题是,对于给定的宽度,它显示每行上有4个方框,但它们都是左对齐的,右边有一些空白区域,我怎样才能水平居中每一行?

像这样的东西:http://realworldstyle.com/thumbs_3.html但页面上水平居中的框...

提前致谢,

html css alignment css-float

3
推荐指数
1
解决办法
9838
查看次数

相对定位+绝对定位VS浮动左浮动(你在CSS中使用哪种方法)?

一些网站使用具有相对位置的DIV,然后它们将绝对位置应用于子元素,以便将元素放置在期望的位置(例如,左0或右0).其他人使用浮动,例如浮动:向左或向右浮动.哪一个更好?或者在什么样的情况下他们更好?

由于我使用固定布局,我最好使用相对定位和相对定位?

css position css-float

3
推荐指数
1
解决办法
1319
查看次数

PHP默认函数参数为T_VARIABLE?

我正在尝试提供成员变量作为类方法的默认值.

我知道将变量用作非类函数的默认值是不可能的,但似乎应该有一种方法可以在类中执行此操作.

必须有办法做到这一点 - 也许我只是有错误的语法:

class test{
  private $test = '';

  __construct(){
    $this->test = "whatever";
  }

  function getTest($var = $this->test){
    echo $var;
  }
}
Run Code Online (Sandbox Code Playgroud)

但是这会引发一个错误,例如:

$ this-> test作为函数参数默认值是不允许的.意想不到的T_VARIABLE.

有什么想法吗?

php arguments function

3
推荐指数
1
解决办法
904
查看次数

如何修复IE7浮动组合

我有一个field_wrapper类div,它包含3个子divs field_label,field_input和field_error

我需要将field_label,field_input并排放在前两个下面的field_error中.

请看下面的css代码,知道我是如何实现这一点的,我的问题是它在IE7中不起作用.清除两者应用于field_error不起作用.

即使经过谷歌搜索很长一段时间,我也找不到合适的方法来解决这个问题而不添加HTML标记.请提示css技巧或任何其他方法以避免额外的标记代码

.field_wrapper
{
 clear:both;
}

.field_label
{
 float:left;
 width:40%;
}
.field_input
{
 float:left;
 width:40%;
}
.field_error
{
 clear: both;
 color:#FF0000;
 float: right;
 text-align:left;
 width: 60%;
}

<form method="post" action="http://localhost/locations/add">
 <div class="field_wrapper">
  <div class="field_label">
   <label for="location_add_name">Name</label>
  </div>
  <div class="field_input">
   <input type="text" id="location_add_name" value="" name="name">
  </div>
  <div class="field_error">
   <p>The Name field is required.</p>
  </div>
 </div>
 <div class="field_wrapper">
  <div class="field_label">
   Address
  </div>
  <div class="field_input">
   <textarea id="location_add_address" rows="12" cols="90" name="address"></textarea>
  </div>
  <div class="field_error">
  </div>
 </div>
 <div class="form_submit">
  <input type="submit" value="Add" …
Run Code Online (Sandbox Code Playgroud)

css clear css-float internet-explorer-7

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

Python错误地将字符串浮动

我收到

TypeError: Can't convert 'float' object to str implicitly
Run Code Online (Sandbox Code Playgroud)

使用时

Gambler.pot += round(self.bet + self.money * 0.1)
Run Code Online (Sandbox Code Playgroud)

锅,赌注和金钱都是双打(或至少应该是).我不确定这是否是另一个Eclipse的东西,但我如何让这行编译?

代码在何处bet和money初始化:

class Gambler:
    money = 0
    bet = 0
Run Code Online (Sandbox Code Playgroud)

测试用例:

number = 0
print("Here, the number is a {0}".format(type(number)))
number = input("Enter in something: ")
print("But now, it has turned into a {0}".format(type(number)))
Run Code Online (Sandbox Code Playgroud)

测试用例的输出:

Here, the number is a <class 'int'>
Enter in something: 1
But now, it has turned into a <class 'str'>
Run Code Online (Sandbox Code Playgroud)

显然,input()正在将其更改为字符串.

编辑:最后解决了问题(我认为)

self.bet …
Run Code Online (Sandbox Code Playgroud)

python string floating-point python-3.x

3
推荐指数
1
解决办法
4387
查看次数

如何将float插入到右侧语言环境中的SQL表中

我必须将浮点值插入到不同的SQL Server中.每个人都可以有不同的语言环境,所以在一个语境中,表示可以是"42,2"而另一个是"42.2"或其他.我应该如何构建查询,以便它可以在任何SQL Server中工作?

在构造查询之前,我需要检测服务器的语言环境吗?

.net sql-server floating-point localization

3
推荐指数
1
解决办法
5698
查看次数

如何更改浮动元素的顺序?

我几乎没有float:right在我的CSS中使用,现在我做了,并遇到了一个恼人的问题.我将菜单项浮动到右侧

我的HTMl

    <ul id="extMenu">
        <li>
            <a href="#">Home</a>
        </li>
        <li>
            <a href="#">Feedback</a>
        </li>
        <li>
            <a href="#">Contact</a>
        </li>
    </ul>
Run Code Online (Sandbox Code Playgroud)

我的CSS

    #extMenuBlock {
    }
        #extMenuBlock ul#extMenu { 
            list-style:none;
            padding:0;
            margin:0; 
        }
        #extMenuBlock ul#extMenu li { 
            float:right;
            padding:5px; 
        }
Run Code Online (Sandbox Code Playgroud)

Now when the items are float, I receive my menu is this order Contact Feedback Home, but I want them in opposite order ie Home Feedback Contact

html css css-float

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