我已经编写了一些代码来从http://csc.blockexp.info/ext/summary提供的json返回值" lastPrice“,但它将返回值作为8.503E-5,而不是所需的lastPrice。
{"data":[{"difficulty":159.63461978,"supply":33494475.4445624,"hashrate":"11.2889","lastPrice":0.00008503,"connections":24,"blockcount":1136720}]}
$jsonCSC = file_get_contents('http://csc.blockexp.info/ext/summary');
$dataCSC = json_decode($jsonCSC,true);
print_r($dataCSC);
$priceCSC = $dataCSC["data"][0]["lastPrice"];该数组的打印方式如下:
Array ( [data] => Array ( [0] => Array ( [difficulty] => 110.1356266 [supply] => 33494245.423562 [hashrate] => 10.5306 [lastPrice] => 8.503E-5 [connections] => 24 [blockcount] => 1136696 ) ) )正如您所看到的,lastPrice不是file_get_contents链接的最后价格。我不知道E-5是从哪里来的,也不知道为什么返回的值是8.503而不是浮点值。
@enkrate指出,is与E-5的浮点数一样是完全有效的!
发布于 2015-11-12 10:53:03
8.503E-5实际上是浮点数的有效PHP语法。有关更多信息和示例,请参阅PHP documentation for floating point numbers。
https://stackoverflow.com/questions/33663553
复制相似问题