久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <bdo id='NiKrm'></bdo><ul id='NiKrm'></ul>
  • <i id='NiKrm'><tr id='NiKrm'><dt id='NiKrm'><q id='NiKrm'><span id='NiKrm'><b id='NiKrm'><form id='NiKrm'><ins id='NiKrm'></ins><ul id='NiKrm'></ul><sub id='NiKrm'></sub></form><legend id='NiKrm'></legend><bdo id='NiKrm'><pre id='NiKrm'><center id='NiKrm'></center></pre></bdo></b><th id='NiKrm'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='NiKrm'><tfoot id='NiKrm'></tfoot><dl id='NiKrm'><fieldset id='NiKrm'></fieldset></dl></div>
    <legend id='NiKrm'><style id='NiKrm'><dir id='NiKrm'><q id='NiKrm'></q></dir></style></legend>

        <small id='NiKrm'></small><noframes id='NiKrm'>

        <tfoot id='NiKrm'></tfoot>
      1. 在 PHP 中處理貨幣值的最佳實踐?

        Best practice for working with currency values in PHP?(在 PHP 中處理貨幣值的最佳實踐?)
        <i id='RDHmD'><tr id='RDHmD'><dt id='RDHmD'><q id='RDHmD'><span id='RDHmD'><b id='RDHmD'><form id='RDHmD'><ins id='RDHmD'></ins><ul id='RDHmD'></ul><sub id='RDHmD'></sub></form><legend id='RDHmD'></legend><bdo id='RDHmD'><pre id='RDHmD'><center id='RDHmD'></center></pre></bdo></b><th id='RDHmD'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='RDHmD'><tfoot id='RDHmD'></tfoot><dl id='RDHmD'><fieldset id='RDHmD'></fieldset></dl></div>

          <bdo id='RDHmD'></bdo><ul id='RDHmD'></ul>
              1. <small id='RDHmD'></small><noframes id='RDHmD'>

                <legend id='RDHmD'><style id='RDHmD'><dir id='RDHmD'><q id='RDHmD'></q></dir></style></legend>
                  <tbody id='RDHmD'></tbody>

              2. <tfoot id='RDHmD'></tfoot>

                  本文介紹了在 PHP 中處理貨幣值的最佳實踐?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我需要在 PHP 中對貨幣值進行加法、乘法和比較,并且需要確保精確到一分錢.

                  I need to add, multiply and compare currency values in PHP and need to be sure that it is exact down to a single cent.

                  一種方法是將所有內容存儲在浮點數中,在每次操作前后使用round,并在比較相等性時使用mind machine epsilon.很麻煩,恕我直言.

                  One way is to store everything in float, use round before and after each operation and mind machine epsilon when comparing for equality. Quite cumbersome imho.

                  另一種方法是以整數數據類型將整個內容存儲為美分,另外記得在我使用數據庫時來回轉換(mysql,我使用十進制數據類型).不優雅,還有很多錯誤陷阱,恕我直言.

                  Another way is to store the whole thing as cents in integer data types, plus remember to convert back and forth anytime I work with the database (mysql, where I use the decimal data type). Inelegant, and many error pitfalls, imho.

                  另一種方法是發明我自己的數據類型",將所有值存儲在字符串(34.12")中并創建我自己的數學替換函數.這些函數會在內部將值轉換為整數,進行計算并再次將結果輸出為字符串.令人驚訝的復雜,恕我直言.

                  Another way is to invent my own "datatype", store all values in strings ("34.12") and create my own mathematical replacement functions. These function would convert the value to integers internally, do the calculation and output the result again a strings. Suprisingly complicated, imho.

                  我的問題:在 PHP 中處理貨幣值的最佳實踐是什么?謝謝!

                  My question: what is the best practice for working with currency values in PHP? Thanks!

                  推薦答案

                  讓我自己回答這個問題.最佳實踐是創建一個金額"類.此類在內部將數量存儲為整數形式的美分,并提供 getter、setter、數學函數,如加、減和比較.干凈多了.

                  Let me answer this myself. Best practice would be to create a "money amount" class. This class stores the amount internally as cents in integers, and offers getters, setters, math functions like add, subtract and compare. Much cleaner.

                  這篇關于在 PHP 中處理貨幣值的最佳實踐?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
                    <tfoot id='O1G96'></tfoot>
                    <legend id='O1G96'><style id='O1G96'><dir id='O1G96'><q id='O1G96'></q></dir></style></legend>
                      <bdo id='O1G96'></bdo><ul id='O1G96'></ul>
                    • <small id='O1G96'></small><noframes id='O1G96'>

                      <i id='O1G96'><tr id='O1G96'><dt id='O1G96'><q id='O1G96'><span id='O1G96'><b id='O1G96'><form id='O1G96'><ins id='O1G96'></ins><ul id='O1G96'></ul><sub id='O1G96'></sub></form><legend id='O1G96'></legend><bdo id='O1G96'><pre id='O1G96'><center id='O1G96'></center></pre></bdo></b><th id='O1G96'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='O1G96'><tfoot id='O1G96'></tfoot><dl id='O1G96'><fieldset id='O1G96'></fieldset></dl></div>

                            <tbody id='O1G96'></tbody>

                          1. 主站蜘蛛池模板: 日韩欧美一区二区在线播放 | 91在线区 | 国产一区 日韩 | 91精品在线播放 | 亚洲精品欧洲 | 91视频网 | 51ⅴ精品国产91久久久久久 | 国内精品视频 | 日韩区| 成人在线视频看看 | 精品国产一区二区三区日日嗨 | 久久精品亚洲国产奇米99 | 91久久精品视频 | 日韩三级在线 | 免费成人高清在线视频 | 在线免费黄色 | av影片在线 | 免费视频一区 | 国产精品毛片一区二区三区 | 国产精品久久性 | 午夜小视频在线观看 | 国产超碰人人爽人人做人人爱 | a级在线免费视频 | 99色综合| 欧美日韩在线视频一区 | 欧美天堂在线 | 人人干人人舔 | 日韩免费一区 | 国产午夜av片 | 中文一区二区 | 亚洲国产成人精品久久久国产成人一区 | 精品在线观看一区 | 国产婷婷 | 国产日韩亚洲欧美 | 免费中文字幕日韩欧美 | 一本一道久久a久久精品蜜桃 | 丁香久久| 免费毛片www com cn| 日本成人午夜影院 | 一区二区三区免费 | 国产农村妇女精品一区 |