Home Backend Development PHP Tutorial 问一个FLOAT的有关问题

问一个FLOAT的有关问题

Jun 13, 2016 pm 01:44 PM
float sec time

问一个FLOAT的问题
//$usec:当前微秒数,$sec:当前秒数
list ( $usec, $sec ) = explode ( ' ', microtime () );
$time1 = ( float ) $usec + ( float ) $sec;

list ( $usec, $sec ) = explode ( ' ', microtime () );
$time2 = ( float ) $usec + ( float ) $sec;

echo $time2 - $time1;

结果输出一个类似这样的数:3.40938568115E-5 

问题:
单独打印$usec和$sec,输出这样的数:0.95312700 1326693637
$time输出类似这样的数:1326693637.95
那为什么用$time1-$time2输出成了“3.40938568115E-5 ”???

谢谢
 

------解决方案--------------------

探讨

引用:

可以自己定义格式
PHP code

echo sprintf('%.16F', $time2 - $time1);

我现在不解的是为什么默认会出来这种情况。。。

------解决方案--------------------
因为数值太小了,无法用小数表示,所以只能有科学计数法表示
------解决方案--------------------
因为你的 $time2 - $time1 数值太小,大概等于 0.0000340938568115
这样前面的几个0影响精度显示,所以自动改为科学计数法
3.40938568115E-5 相当于 3.40938568115 * 10 ^ -5
------解决方案--------------------
探讨

其实我的意思是:
$time1和$time2都是类似于这样的数:1326693637.95
那他们相减也应该是两位的小数啊,为什么小数点后面出来那么多??
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The U.S. spot ETH ETF listing plan is postponed, and the SEC requires a revised S-1 form to be submitted before July 8 The U.S. spot ETH ETF listing plan is postponed, and the SEC requires a revised S-1 form to be submitted before July 8 Jun 30, 2024 pm 08:38 PM

U.S. Spot Ethereum ETF Launch Delayed The U.S. Securities and Exchange Commission (SEC) has delayed the launch of its spot Ethereum exchange-traded fund (ETH ETF) and required issuers to resubmit Form S-1 before July 8. This decision has resulted in the postponement of the planned launch on July 2, with the new launch expected to be in mid-July or later. Background Overview There has been a change in the review process for spot Ethereum ETFs, with Bloomberg’s senior ETF analyst Eric Balchunas commenting on the SEC’s latest decision and its impact on market expectations. Earlier last month, SEC Chairman Gary Gensler

SEC seeks $5.3 billion fine against Terraform Labs and Do Kwon SEC seeks $5.3 billion fine against Terraform Labs and Do Kwon Apr 24, 2024 pm 03:25 PM

The agency is also seeking conduct-based and "compliance with the law" injunctions. The U.S. Securities and Exchange Commission (SEC) wants to fine Terraform Labs and its former CEO DoKwon nearly $5.3 billion for violations of U.S. securities laws and fraud charges. The agency detailed its requested fine in an April 19 legal filing. The SEC is primarily seeking $4.2 billion in disgorgement and $545.7 million in prejudgment interest. The purpose of the illegally obtained proceeds is to force TerraformLabs and Kwon to return the unfair benefits they obtained between June 2021 and May 2022 through the following channels: first, selling tokens to institutional investors; second, through their relationship with Genesi

The SEC Temporarily Suspends Its Allegations That SOL, ADA, and MATIC Are Unregistered Securities The SEC Temporarily Suspends Its Allegations That SOL, ADA, and MATIC Are Unregistered Securities Jul 31, 2024 am 12:25 AM

This decision comes amid the ongoing legal proceedings against Binance, one of the world's leading cryptocurrency exchanges.

In this article, learn about SEC and Fidelity talking about open staking for crypto ETFs! Discussing ETF staking, stablecoins and DeFi regulation In this article, learn about SEC and Fidelity talking about open staking for crypto ETFs! Discussing ETF staking, stablecoins and DeFi regulation Mar 04, 2025 am 11:09 AM

The minutes recently released by the Securities and Exchange Commission (SEC) show that the SEC Cryptocurrency Working Group (CTF) has held talks with Fidelity Investment and MITRE to discuss many key issues in crypto asset regulation. SEC and Fidelity: Pledge of crypto ETFs and related rules At this meeting, SEC and asset management giant Fidelity had in-depth exchanges on the issue of crypto asset supervision. Discussions cover: Customer protection rules related to brokerage dealers' interaction with digital asset securities (Rule15c3-3). Formulate standardized listing rules for digital asset exchange-traded products (ETPs). Clarify ETF pledged assets and operating specifications. Monitoring of blockchain tokens and financial instrument-related rewards (such as pledge income, liquidity mining)

Why Cancelled SEC vs Ripple Meeting Shouldn't Worry XRP Holders Why Cancelled SEC vs Ripple Meeting Shouldn't Worry XRP Holders Aug 01, 2024 pm 10:02 PM

The U.S. Securities and Exchange Commission (SEC) has cancelled a closed-door meeting that was initially scheduled for today at 2 PM Washington time.

The SEC No Longer Asks the Court to Deem the Tokens Named in Its Lawsuit against Binance as Securities The SEC No Longer Asks the Court to Deem the Tokens Named in Its Lawsuit against Binance as Securities Jul 30, 2024 pm 06:29 PM

The United States Securities and Exchange Commission (SEC) no longer asks the court to decide and deem the tokens named in its lawsuit against the crypto exchange

SEC issues Wells Notice against Uniswap, involving securities regulations SEC issues Wells Notice against Uniswap, involving securities regulations Apr 11, 2024 pm 02:58 PM

A Wells Notice is usually issued as a preliminary step before litigation. The U.S. Securities and Exchange Commission (SEC) issued a Wells Notice to UniswapLabs, the operating entity of Uniswap, a decentralized exchange based on the Ethereum chain. About Wells Notice A Wells Notice is a formal notice issued by the U.S. Securities and Exchange Commission (SEC) before it prepares to take enforcement action against an individual or company. This notification signals that the regulator has completed its investigation and found a violation, and the recipient of the notification has an opportunity to object or explain before formal enforcement action begins. Although the Wells Notice is not a necessary process required by law, the SEC and the National Association of Securities Dealers (N

To strengthen cryptocurrency regulation, Nigeria SEC launches 30-day registration period To strengthen cryptocurrency regulation, Nigeria SEC launches 30-day registration period Jun 22, 2024 pm 10:59 PM

The Nigeria Securities and Exchange Commission (SEC) recently launched a new registration scheme aimed at accelerating the registration process for Virtual Asset Service Providers (VASPs). According to the West African country’s securities market regulator, the move is an important amendment to existing rules aimed at bringing the regulatory framework up to date and adapting to the growing complexity of the cryptocurrency ecosystem. The Nigerian SEC sets a 30-day deadline to accelerate VASP registration. In March this year, the Nigerian SEC announced changes to digital asset issuance, issuance platforms, trading and custody rules. The most eye-catching one is to increase the VASP registration fee from N30 million. (approximately US$20,161) to 150 million naira (approximately US$100,806). This change triggered an industry

See all articles