Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Solved: Scriptrunner error with rounding

Marc Rexer November 21, 2018

Dear Community,

as I am not a programmer this is my first try for a scripted field.

Unfortunately I got an error message I don´t understand why it occured:

screenshot_2018-11-21_DIA_no05.png

Can you please help?

1 answer

1 accepted

0 votes
Answer accepted
Tom Lister
Community Champion
November 21, 2018

Hi @Marc Rexer

To use BigDecimal your script should start with an

import java.math.BigDecimal

Although the groovy runner may provide that

 

change -1 and 100 constants to -1f and 100f to prevent result being cast to int

 

Marc Rexer November 21, 2018

Hi Tom,

Thank you for your reply!

I added the import as also the "f"´s but the error messages still present:

screenshot_2018-11-21_DIA_no06.png

The crazy thing is that I get the result regardslessof the error message...

Do you see the failure?

Tom Lister
Community Champion
November 21, 2018

Hi

the editor is checking inferred type ie your result is just a def, so it’s more a warning of unpredictable results

try adding as double 

at run time the method gets a real object which can apply a method to

Marc Rexer November 21, 2018

Hi Tom,

great, thank you!

Suggest an answer

Log in or Sign up to answer