I'm looking for a way to round a value to .0 or to .5,

so 1,34 would become 1.5, 1.22 would become 1.0, 1.63 would become 1.5, and 1.79 would become 2.0.

Is there a function to accomplish this or would I have to make my own?

Thanks in advance

Attribution to: Thomas

# Possible Suggestion/Solution #1

You have ceil and floor Math functions to achieve this. Take a look on this document for examples,

http://mysalesforcecode.blogspot.in/2012/11/floor-function-in-salesforce.html

https://success.salesforce.com/ideaView?id=08730000000KRnWAAW

http://www.salesforce.com/us/developer/docs/dbcom_apex250/Content/apex_methods_system_math.htm

Attribution to: Bforce

# Possible Suggestion/Solution #2

As requested, here is my solution: I made my own function that would return the correct value

```
public Double myFunction(double input){
Double temp = Math.floor(input);
input -= temp;
if (input >= 0.5) return temp + 0.5;
return temp;
}
```

Attribution to: Thomas

This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/34240