+ Start a Discussion
Michael3.BrownMichael3.Brown 

Round Function works on every number except for 10?

Hello, On my VF page, we wish to display numbers as whole numbers, so I have used the round function to round the numbers appropriately.

 

<TD align="center">{!ROUND(subtotalAmericasMedQ1,0)}</TD>

 This is working on all my data, except for the number 10. Instead of diplaying "10" on the VF page, it displays "1E+1". 11 and 9 display correct, but for some reason the number 10 is changed to 1E+1. Has anyone else come across this error and have any tips I might be able to try to get it to actually display the number 10.

 

Thanks,

Mike

Best Answer chosen by Admin (Salesforce Developers) 
Shashikant SharmaShashikant Sharma

Use this VFP 

 

<apex:outputLabel value="{!TEXT(ROUND(subtotalAmericasMedQ1,0))}"></apex:outputLabel>

 It will solve your issue.

All Answers

Shashikant SharmaShashikant Sharma

Worked fine for me

 

Controller

public class roundController{

public Decimal subtotalAmericasMedQ1 { get; set; }

public accountController()
{
subtotalAmericasMedQ1 = 10.3;
}
}

 

I have tried with 10.0,10.3, 10.5, 10.9 all worked fine 

VFP

<apex:page controller="roundController">
<apex:form >
   <apex:outputLabel value="{!ROUND(subtotalAmericasMedQ1,0)}">    
    </apex:outputLabel>
</apex:form>
</apex:page>

 let me know if i am missing something in understanding.

Michael3.BrownMichael3.Brown

Hey Shashikant,

 

You've pretty much nailed my setup. However, I used public Double instead of public Decimal. Do you think that would make a difference?

 

But other than that, it's pretty straight forward. The two values that are rounding to 1E+1 are 9.9 and 9.5

 

Thanks,

Mike

Shashikant SharmaShashikant Sharma

Use this VFP 

 

<apex:outputLabel value="{!TEXT(ROUND(subtotalAmericasMedQ1,0))}"></apex:outputLabel>

 It will solve your issue.

This was selected as the best answer
Michael3.BrownMichael3.Brown

Great. Thanks a ton, Shashikant!!! That fixed my issues!!