Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4323968
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:04:12+00:00 2026-05-21T09:04:12+00:00

Im using Jruby (thats ruby anyway, running under jvm :D ) with marathon test

  • 0

Im using Jruby (thats ruby anyway, running under jvm 😀 ) with marathon test (a java swing app) and im having a little trouble handling currency numbers.

I dont use Rails (dont know if i can use rails even with marathon) and i dont know / didnt found HOW to convert a string to a decimal or a double.

My code with maraton is something like this

$saldoDisponivel = get_p("com.company.app.view.layout.objetos.JTextField1", "Text")

In other words, saldoDisponivel gets a string (ex: 3.232,20).
I also have another string valor = “100,00” and when i do

$saldoDisponivel = $saldoDisponivel + valor 

Of course i get 3.232,20100,00 (add 2 strings right..lol)

I though ruby could handle those kind stuff more easly.. in java i would convert those on BigDecimails (using java.math.BigDecimal) but on pure Ruby, dont know how.

Thks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:04:13+00:00Added an answer on May 21, 2026 at 9:04 am

    You should use BigDecimal in ruby as well so that you don’t have any floating point errors:

    require 'bigdecimal'
    
    x = '3232.20'
    y = '100.00'
    
    xb = BigDecimal.new x
    yb = BigDecimal.new y
    
    r = xb + xy
    
    r.to_s('F')
    
    > r.to_s('F')
     => "3332.2" 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking at ways to deploy a Ruby on Rails app (running on JRuby)
I'm considering using JRuby on App Engine but have heard that Juby app on
I have a jruby/rails app using: jruby 1.4.0 Rails 2.3.5 ActiveMQ 5.3.0 Mule ESB
I have built a variety of little scripts using Ruby's very simple Queue class,
I am using jruby, i want use pagination for my rails app i used
I'm using jruby-1.5.3 with a rails 2.3.5 app. I've just started playing around with
I have an app that I am migrating from Ruby to JRuby (due to
I have a ruby script which I run using the JRuby Interpreter. The script
I am using Jruby and rails 2.2.2. My problem is I have a migration
I creating a site in JRuby on Rails (JRuby 1.3.0 ). I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.