Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
rounding off values
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Nikhanj  
View profile  
 More options Oct 9 2012, 6:19 am
From: Nikhanj <nikhan...@gmail.com>
Date: Tue, 9 Oct 2012 03:19:29 -0700 (PDT)
Local: Tues, Oct 9 2012 6:19 am
Subject: rounding off values

Hi,
I have a number like this a=0.123456789. I want to round this value to two
decimal places. How to do this in gremlin ????


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Hunger  
View profile  
 More options Oct 9 2012, 6:26 am
From: Michael Hunger <michael.hun...@neotechnology.com>
Date: Tue, 9 Oct 2012 12:26:08 +0200
Local: Tues, Oct 9 2012 6:26 am
Subject: Re: [Neo4j] rounding off values
it is groovy after all.

(0.452334D).round(2)

Am 09.10.2012 um 12:19 schrieb Nikhanj:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nikhanj  
View profile  
 More options Oct 9 2012, 6:29 am
From: Nikhanj <nikhan...@gmail.com>
Date: Tue, 9 Oct 2012 03:29:55 -0700 (PDT)
Local: Tues, Oct 9 2012 6:29 am
Subject: Re: [Neo4j] rounding off values

I tried but got  
No signature of method: java.math.BigDecimal.round() is applicable for argument types: (java.lang.Integer) values: [2]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nikhanj  
View profile  
 More options Oct 9 2012, 6:31 am
From: Nikhanj <nikhan...@gmail.com>
Date: Tue, 9 Oct 2012 03:31:14 -0700 (PDT)
Local: Tues, Oct 9 2012 6:31 am
Subject: Re: [Neo4j] rounding off values

When i try this 0.12345.round(2), i get exception but on doing
0.12345D.round(2) i am able to get the result. Why so???


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Hunger  
View profile  
 More options Oct 9 2012, 6:47 am
From: Michael Hunger <michael.hun...@neotechnology.com>
Date: Tue, 9 Oct 2012 12:46:53 +0200
Local: Tues, Oct 9 2012 6:46 am
Subject: Re: [Neo4j] rounding off values

if you append a D it is a double.

for bigdecimals there is

1.233434.setScale(2,BigDecimal.ROUND_HALF_UP)

Am 09.10.2012 um 12:31 schrieb Nikhanj:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nikhanj  
View profile  
 More options Oct 9 2012, 7:05 am
From: Nikhanj <nikhan...@gmail.com>
Date: Tue, 9 Oct 2012 04:05:45 -0700 (PDT)
Local: Tues, Oct 9 2012 7:05 am
Subject: Re: [Neo4j] rounding off values

Thanks Michael!!! It works


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marko Rodriguez  
View profile  
 More options Oct 9 2012, 10:04 am
From: Marko Rodriguez <okramma...@gmail.com>
Date: Tue, 9 Oct 2012 08:04:41 -0600
Local: Tues, Oct 9 2012 10:04 am
Subject: Re: [Neo4j] rounding off values

Hi,

You can simply use:

        Math.round(a);

        gremlin> a=0.123456789
        ==>0.123456789
        gremlin> Math.round(a)
        ==>0

To decide to what decimal you want, you can multiply and divide:

        gremlin> Math.round(a * 100) / 100
        ==>0.12

Note that Gremlin has full access to the Java and Groovy APIs, so:

        http://stackoverflow.com/questions/153724/how-to-round-a-number-to-n-...

HTH,
Marko.

http://thinkaurelius.com

On Oct 9, 2012, at 4:19 AM, Nikhanj wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »