Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
パーセントの計算を実装する方法:
$x=3; $y = 100\$x; // 3.333.. $x*$y - and here I need to get 100 without Observational error
何か案は?
バックスラッシュ ( \) は除算記号ではありません。/除算記号を使用する必要があります。
\
/
number_format()これは、小数点以下 2 桁 (100 分の 1 位) に丸められる which を使用した例です。
number_format()
$x = 3; $y = 15; $percent = $x/$y; $percent_friendly = number_format( $percent * 100, 2 ) . '%'; // change 2 to # of decimals