search for: bigdecim

Displaying 20 results from an estimated 68 matches for "bigdecim".

Did you mean: bigdecimal
2006 Mar 31
6
BigDecimal + Float => Float?
I was just playing around in irb and noticed that while BigDecimal + Integer => BigDecimal, BigDecimal + Float => Float. Is there any reason for this? It seems inconsistent and means you have to check the class of any number you add to a BigDecimal, which looks very un-Ruby-like to me. Ashley
2010 Dec 23
36
Weird issue with converting floats to integer
Any idea why this calculates the integer the way it does? irb> ("291.15".to_f * 100.0).to_i => 29114 Thanks, Tom -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to
2008 Nov 07
15
any tricks re using " eql(5.5)", but where 5.5 is a decimal not float?
-- Sent from my mobile device
2006 Jul 09
6
Float -> BigDecimal
So, I''m personally cool with this change (patch from #5454, applied in [4596]), and I''ll make it work for Oracle tomorrow. But just wondering if folks considered the performance impact of the change? From a simple test it seems that BigDecimal math is about twice as slow as using Floats.
2008 Jan 19
1
Decimals are being converted to Bigdecimals!!!!!
...=> 2 I''ve run the migration and restarted the server. I also looked at the Mysql tables to verify that the migration ran correctly, and the fields look like they''re set up right ( DECIMAL(8,2) ). The problem is that when I access these columns in the console, they show up as Bigdecimal and it''s messing up my calculations. Here''s what it looks like from the rails console: >> Lineitem.find(34).price => #<BigDecimal:31e4c74,''0.3E4'',4(12)> >> Payment.find(23).amount => #<BigDecimal:31b8480,''0.4125E4''...
2008 Jun 11
1
Resourse route in namespace with prefix error
...g trades/buys/index.html.erb where line #12 raised: trades_buy_url failed to generate from {:contract_id=>#<Trades::Buy id: 5951, asset_id: 309, type: "Buy", contract_id: 1, investor_id: 1, date: "2001-09-30", trade_status_id: 1, is_future_operation: false, quantity: #<BigDecimal:7fb8004,''0.2E2'',4(8)>, price: #<BigDecimal: 7fb7fb4,''0.623E1'',8(12)>, total: #<BigDecimal:7fb7f64,''0.1246E3'', 8(12)>, created_at: "2008-06-10 22:49:31", updated_at: "2008-06-10 22:49:31">, :action=>&quo...
2007 Nov 13
4
question about activerecord test_numeric_fields in base_test.rb
There''s a test for activerecord called test_numeric_fields in base_test.rb. here''s the test def test_numeric_fields m = NumericData.new( :bank_balance => 1586.43, :big_bank_balance => BigDecimal("1000234000567.95"), :world_population => 6000000000, :my_house_population => 3 ) assert m.save m1 = NumericData.find(m.id) assert_not_nil m1 # As with migration_test.rb, we should make world_population >= 2**62 # to cover 64-bit platforms...
2010 Jul 08
3
Testing equality
Hello How can I test equality with two objects when they include some attribute that is BigDecimal? if I make something like this: it "should ...whatever" do obj = Factory.create(:my_object) ... MyObject.first.should == obj end. FAILS This fails because the object expected is different from the object gotten, and the only difference are the BigDecimal attributes, that are d...
2009 Feb 03
4
Ruby EE: Problem with BigDecimal
I have a strange problem with my setup of Passenger and Ruby Enterprise Edition. Sometimes the loading of BigDecimals from the database and session fails (silently) and the variable containing the BigDecimal is just empty. I cannot pinpoint where/when/how it happens, and it IS only periodic. I am using the newest versions of both Passenger and REE - I have even tried to run with latest commit of both: the pro...
2008 Aug 01
2
BigDecimal to letters
Is there a method that converts BigDecimal 1520.0 to "one thousand five hundred and twenty"? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, sen...
2006 May 25
3
Storing BigDecimal in the db
I need to do some precise math, going to 12-14 decimal places, so I''m using BigDecimal. How can I store this in a db? I''m using postgresql 8.1.0, if that matters at all. I found a plugin [1] but it gives me the error "You have a nil object when you didn''t expect it! The error occurred while evaluating nil.each_pair," with no line number. The plugin...
2006 Apr 09
16
Mapping to BigDecimals instead of Floats
Hi everyone, I''m new to Rails and Ruby, and have been working my way through the Pickaxe and Agile Rails books for the last week or so. With a background in payroll apps I found that the default ActiveRecord mapping of decimal columns to float variables really bothered me! Financial calcs need high levels of accuracy and floats just don''t give you that. I know there are a bunch
2007 Aug 30
3
Rails - depot application
I''m doing the depot example in the Agle Web development book. I''m getting this error: "undefined method `product'' for #<BigDecimal:331ce70,''0.21E1'',8(8)> " "Extracted source (around line #9): 8: for item in @items 9: product = item.product 10: -%> 11: <tr> 12: <td><%= item.product%></td>" this is display_cart.rhtml line_item.rb has: "class LineItem...
2010 Oct 22
0
Overriding to_s method of BIgDecimal
I am overriding to_s method of BigDecimal class as below and its working fine. Wanted to confirm is there any other better way to do this ? Thanks! 49 class BigDecimal 50 alias :old_s :to_s 51 def to_s 52 return to_i.to_s if eql? to_i 53 self.old_s 54 end 55 end -- sαη∂ιρ Rαηѕιηg --- blog www.funonrails.com twit...
2009 Oct 07
1
output validations errors form causing type error?
...customer_select_state"=>["^State/ Province must be a U.S. state selected from the drop down list for customers in United States"], "card_verifiation"=>[["is required"]]}, @base=#<Order id: nil, created_at: nil, updated_at: nil, customer_id: nil, gst: #<BigDecimal:105d342c0,''0.0'',9(18)>, qst: #<BigDecimal: 105d33ed8,''0.0'',9(18)>, shipping_ca: #<BigDecimal:105d33ac8,''0.0'',9(18) >, shipping_us: #<BigDecimal:105bfb840,''0.7E1'',9(18)>, currency: "USD", status:...
2006 Apr 01
7
BigDecimal column type?
I was hoping 1.1 would provide a way to map SQL "decimal" column types to BigDecimal values, since BigDecimal is part of the Ruby standard api as of 1.8. But I don''t see any support for that in the migration documentation, and when I try to let Active Record do the mapping for me, it seems to coerce the column into a Float (as the AwdwR book says). Is it really ther...
2012 Feb 21
0
nil can't be coerced into BigDecimal Options
hi guys im playing with RoR with the environment of rails 3 ruby 1.9 i got stuck in nil can''t be coerced into BigDecimal error i need to get the total cost of the products inside the cart i know where the problem is(i think) but i almost did every thing cart/show.html.rb <div class="cart_title" >Your Cart</div> <table> <% for item in @cart.line_items %> <tr>...
2006 Jun 12
6
Storing "money" in databases
Hiall, I''m wondering what''s common practice when dealing with money values stored in databases. I like the idea of storing all the values as integers, i.e. all the values in eurocents not euros. Then I need to multiply all values the users enter by 100 before storing them in the database. Now the question is, what''s the most efficient and dryest way to do this?
2007 Oct 19
14
Agile Web Development Book, need a bit of help
...ed the code from the book into the view, it threw this error. If anyone could give me some hints where I should be looking I''d appreciate it. NoMethodError in Store#display_cart Showing app/views/store/display_cart.rhtml where line #5 raised: undefined method `product'' for #<BigDecimal:47a81c8,''0.9E3'',4(12)> Extracted source (around line #5): 2: <table> 3: <% 4: for item in @items 5: product = item.product 6: -%> 7: <tr> 8: <td><%= item.quantity %></td> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----...
2010 Sep 04
2
Decimal numbers pain
Hi, What do you guys use to definitely handle decimal numbers? This is getting me crazy! I use BigDecimal, but it craps out of the input number is something like "14,53", Rails transforms it as 14.0 Any solution? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this gr...