BigDecimal - always change own value after reloading site page

19 views
Skip to first unread message

Psycho Shine

unread,
Jan 19, 2015, 10:04:08 AM1/19/15
to rubyonra...@googlegroups.com
hello all.
I was noticed that BigDecimal attribute in my db row changing every reloading.


sum: #<BigDecimal:4add7d0,'0.9E0',9(36)>
ctrl+r
sum: #<BigDecimal:639f200,'0.9E0',9(36)>
ctrl+r
sum: #<BigDecimal:594ceb0,'0.9E0',9(36)>

Is it ok?

Daniel Evans

unread,
Jan 19, 2015, 12:18:16 PM1/19/15
to rubyonra...@googlegroups.com
The values you see changing, like "4add7d0" aren't actually the decimal value, they are the "address". The actual decimal value is .9E0 so between each of those the *value* is the same. See http://www.ruby-doc.org/stdlib-2.1.1/libdoc/bigdecimal/rdoc/BigDecimal.html#method-i-inspect for more information. Try using ".to_s" to see just the decimal value.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7ed48cd2-bb8c-493c-aa10-4663861f7b97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Daniel Evans
Reply all
Reply to author
Forward
0 new messages