Re: [問題] 資料型態問題
是精度的問題。
AS3's Number type, like Java's or C++'s 'double' type, store floating-point
values using binary fractions, not decimal fractions, so there is some loss of
precision occuring. There is no fractional-decimal type in AS3.
I'll leave it to folks in the developer community working on financial
applications to explain how they work around this limitation.
Gordon Smith
Adobe Flex SDK Team
http://zengrong.net/post/1186.htm
解決方式或許可以採用 toFixed() ?
http://livedocs.adobe.com/flash/9.0_tw/ActionScriptLangRefV3/Number.html
※ 引述《pino0707 (威士登)》之銘言:
: var num:Number=0.7;
: var num2:Number=0.3;
: trace(num-num2)
: 會呈現0.399999997這種數字...
: 這是什麼原因呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.161.94.63
※ 文章網址: http://www.ptt.cc/bbs/Flash/M.1400103553.A.D14.html
→
05/15 15:08, , 1F
05/15 15:08, 1F
→
05/15 15:08, , 2F
05/15 15:08, 2F
→
05/15 20:02, , 3F
05/15 20:02, 3F
討論串 (同標題文章)
Flash 近期熱門文章
PTT數位生活區 即時熱門文章