Questions tagged [decimal]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
4answers
645 views

How to get the fractional part of a number in apex

I need to get the number after de decimal point. For example I have: 344.567 And I need to get in a variable 567. I've tried the next: decimal d=43.3432332343344; String s = String.valueOf(aa); ...
0
votes
1answer
151 views

Get full length decimal value of a managed field with decimal places set to 2

I have a Managed field Number(16, 2) of which number of decimal places cannot be edited. For Example, if I enter 1.2391276549 into that field, It is displayed as 1.24 (as we know that salesforce ...
0
votes
1answer
81 views

Is it possible to convert numbers from Base 10 to Base Alphabet and back again using formula fields?

For shits and giggles, I am working to create a spreadsheet application (comparable to Excel, inspired by The SCells Spreadsheet) on Salesforce.com Each spreadsheet cell will correspond to one ...
4
votes
1answer
68 views

Round Decimal and .format() it into a localized output String with more than 3 decimal places

Until today I was very happy with this utility method public static string roundNumber(decimal d, integer precision) { if(d == null) return ''; string separator = (1.01).format().substring(1,...
0
votes
1answer
65 views

Sum up values(currency) from the list

Decimal totalReceived = 0.00; List<Money_Received__c> moneyReceived = [Select Amount_Received__c,Reservation__r.Total_Recieved__c from Money_Received__c where Id =: reservationId]; for(...
0
votes
4answers
332 views

APEX Trigger Round decimal place to a specific number

I am working on a trigger that sets the price of that a customer pays us. There are requirements that I am struggling with meeting. If the decimal for the price is lower than .95 then it needs to be ...
0
votes
1answer
331 views

currency field multiplied by another number rounded down its decimals

We have a currency field which should produce a currency result with decimal points after multiplication. However, the decimal part was consistently round down to zero. All fields in the formula have ...
0
votes
1answer
134 views

Salesforce storing decimal values to 3 digits internally , inspite of only 2 decimal field permitted on field

I have a discount and currency field, While saving formula, currency field gets filed in, While saving currency , discount field should get filled in. However, The problem is , Salesforce by ...
1
vote
1answer
31 views

Is SoapType.Decimal a valid value?

Documentation for SoapType enum does not list Decimal as a member. But it's possible to compile a class which uses SoapType.Decimal. Could this be a problem if we use such code in a managed package?
0
votes
1answer
208 views

Decimals with 2 digits Salesforce

I have 4 Decimals fields with 2 digits, A, B, C and D. When I tried to multiply A*B and put them into C the C and D should be equals but they are not. What is the best practice to use the Decimal ...
1
vote
1answer
2k views

Format decimal number with thousand separator with a dot (.)

I would like to format a visualforce variable '{!TotalE}' with a thousand separator as . notation for example 123386258.00 becomes 123.386.258 I have tried examples of outputtext 'value="{0, ...
2
votes
1answer
1k views

Saving null value to decimal field using apex

I just wanted to check is it possible to save empty value or null value to a decimal field using apex. Let us take that there is a number field by name Count__c, which needs to be set as blank when ...
1
vote
1answer
305 views

How can I convert String To Decimal dynamically in VF Page?

I've a map in controller. public Map<ID, String> mapOfChargeTypeToItems{get; set;} The String(Value part) may contain a String(Alphanumeric) mapOfChargeTypeToItems.put(objChargeType.id, ...
0
votes
1answer
37 views

Method does not exist - {List}.get(Decimal)

I get errors for the last line. Method does not exist - {List}.get(Decimal) opp.Most_Expensive_Competitor_Price__c = oppCompetitorPrices.get(highestPrice); I am trying to populate the ...
0
votes
3answers
1k views

Apex division losing precision

I am having some issues related to the precision with Decimals. Let's take a look at the following scenario: Decimal total = (5 / 3) * 3; System.debug(total) // this will print 4.9999999999999999 ...
1
vote
2answers
2k views

Invalid field count for AggregateResult:

Aggregate count error - please assist and excuse this basic mistake. I am trying to count a number from the query and then to use it in some arithmetic. Tring to get RemainingMonthsDec throws the ...
2
votes
1answer
3k views

Convert a String to a Decimal

in my code I need to put a String contained inside a map in a Decimal variable. Now I have 2 problems, the first one is the format of the String because it can contain ' , ' and ' . ' e.g. '21,31' or '...
0
votes
1answer
280 views

Decimal Number 1.00 displayed 1.0 in VF

I have Number type field that has two decimal values. I am using the same value in my VF to generate quotations. If the value is 1.08 it is reflected 1.08 in VF, but if it is 1.00 then in VF it is ...
1
vote
1answer
2k views

Need AMPScript function to convert string to decimal

In an email I have a variable coming in that is in string format (it's a price). I need to multiply that by another number, which means I need to convert the string to a number in the xx.xx format. ...
1
vote
0answers
74 views

How can I add cents (including .00) with setScale? [duplicate]

If in an Apex class I set some decimal values like so: public List<String> args = new String[] { '0', 'number', '#,###,###.##' }; public String getPrice() { Decimal amount = (lead.Price__c)...
2
votes
1answer
1k views

Number Type, Decimal Points Confusion

We have a number typed field say Min_Distance__c where we have defined, Length=1 and Decimal places=2. But we experienced that salesforce allows to save numbers with more than 2 decimal places. In ...
0
votes
1answer
52 views

Can't insert a record with Number(16, 2) field type

I've to insert, for my test method, an Invoice__c object with a value of Amount_Due__c more than 0. This field is a Formula (Number) with 2 Decimal Places field with this syntax Invoice_Amount__c - ...
4
votes
1answer
2k views

Variable does not exist: Decimal

I have the following code: fieldList = (List<Object>)JSON.deserializeUntyped('['+ JSONValueRights +']'); for(Object fld : fieldList){ Map<String,Object> data = (Map<String,...
1
vote
0answers
376 views

Add comma on input text that reference a decimal value

I have an inner class that has decimal attribute. This attribute is referenced by an input:text field on visual force. My question is how can I add thousand comma separation on this input text? e.g ...
0
votes
2answers
6k views

If decimal is null

I have a query that sometimes returns a value if the current user has a record. If they do not no value is loaded and my vf page does not show a gauge. Today, I have been tweaking the controller to ...
3
votes
1answer
203 views

“Expression cannot be assigned at line X” - Trying to incrementally increase quantity of Decimal value in an <Id,Decimal> map in a for() loop

Scenario: We have a quoting system with a child object called zqu__QuoteCharge__c that acts as the individual line items on the quote. zqu__QuoteCharge__c is also the child of ...
0
votes
0answers
389 views

Unable to convert value 'userAmount' to type 'Integer' for attribute 'maximum'

I am trying to set a visualforce gauge chart to have the maximum value be a currency field from the user record. I can get the field: Decimal userAmount = [Select ISO_Goal__c From User Where Id ...
1
vote
0answers
1k views

Number vs Percent problem

I am seeing some odd behaviour with Numeric vs Percent fields. I have two fields, on separate objects: Percentage Commission on Object A - Number(15,3) Percentage Commission on Object B - Percent(3,...
4
votes
2answers
617 views

Can Decimals be used as Map keys? [duplicate]

I have seen at least one other question where a user has had issues with using Decimals as map keys (his issue was interchangeably using ints vs decimals), but it isn't the same issue I'm having, ...
2
votes
0answers
157 views

Why sales force is rounding up Value?

Why sales force is rounding up Value. I have EnteredLoan Amount (£) 999,999,999,999,999.99. However when i am doing query on Dev. Console it is returning me 1000000000000000. How do i avoid this?
4
votes
3answers
28k views

Function to convert String to Decimal value?

I need to convert String into Decimal. the isNumeric() method is retuning false if value is Decimal. Another alternate: try { Integer x = Integer.valueOf(myString); } catch (exception e) { // ...
0
votes
1answer
66 views

How can i get decimal place upto 4

Below is my code which is giving me decimal places upto 2. But I want to get decimal upto 4. Please help IF( Final_Amount_with_exch_rate__c>= 1000000, TEXT(FLOOR(...
1
vote
1answer
143 views

Decimal field showing incorrect format

This is a very weird situation as I have never seen such anomaly. I created three Decimal fields on an Object and the data in these fields are populated by a trigger. Everything is fine when I see ...
12
votes
3answers
9k views

Decimal or double?

What datatype should I use in Apex Classes when I need to store a number with decimal places. What do you use and why?
1
vote
1answer
2k views

Convert aggregate result to decimal

I need to fetch the AggregateResult 'sett' for each Opportunity in a loop, from a map and convert them into decimals. I've seen Ariel's solution on this post but when I use it, it causes an error ...
0
votes
1answer
446 views

Pulling in currency field from Salesforce into Exact target

Wonder if anyone can help me, I am pulling in a currency field from Salesforce into ExactTarget but I have the following issue: If the currency ends with a zero (i.e. 223.00) the last digit does not ...
5
votes
1answer
475 views

Decimals pretending to be Integers when used in Maps

I came across some very strange behaviour when working with a Map with Decimal keys today. It seems like the Decimal type can't handle Integer assignments properly, but allows them nonetheless. I've ...
0
votes
0answers
196 views

Use comma sign to show precision instead of period sign in Dataloader

I am using Dataloader to upsert some records but my decimals will not load because the values are not valid. The decimal uses a comma sign to separate the whole from the precision (so for example 2,34 ...
3
votes
2answers
129 views

Is there any way to maintain a Decimal scale property without rounding for every operation?

Is there a way to maintain the scale of a Decimal across multiple operations? I thought setScale appears to be a normal set method on the Decimal class. Meaning that you can set the scale, and then ...
0
votes
1answer
6k views

Division in Apex, explain

Integer a = totalRecords.size(); //1250 decimal b = 400; integer block = a/b; //3 The actual result of 1250/400 is 3.125. Because I used integer block, I get 3 as answer. Instead of that if I use ...
1
vote
2answers
2k views

Input field for decimal property

My VF tags: <apex:column > <apex:facet name="header">Sales Price</apex:facet> <apex:inputText value="{!prod.SalesPrice}"/> </apex:column> Controller code: ...
2
votes
3answers
1k views

Why is Salesforce hiding Discount, UnitPrice and TotalPrice decimals?

I've been migrating some QuoteLineItem and OpportunityLineItem records, and I noticed an odd behavior of the Salesforce platform. First, here are the field definitions: Here, we can see that: ...
7
votes
3answers
21k views

How to convert a number into a formatted string?

Note: there is an extensive discussion on converting a string into a decimal. This question asks how to convert a number into a formatted string. Given a decimal variable, how can I convert that ...
1
vote
2answers
862 views

Displaying more than 2 decimals for currency field in Report

I have a one currency field in an object, and I have kept 5 decimal places to that currency field. while showing the same field in a report it is showing only 2 decimal places. How can I change the ...
8
votes
2answers
3k views

Which decimal symbol is used in the current user's Locale

For complicated reasons I need to find out which symbol (dot or comma) is used for Decimals in the current User's Locale. Is there any way to find that out using Apex or formulas?
1
vote
1answer
916 views

Validation for decimal field to restrict blank values and string values in visual force page

I have a visual force page in which I have a field to accept decimal values. I can restrict the user from entering 0.0 and null values, but I cant do the same for '' (Empty String). Is there any ...
7
votes
1answer
939 views

The Do's and Don'ts of currency calculations in Apex

Ok, I am not a math expert, but I know about the basics of rounding problematics in programming languages. In one of my apps, I do some quite complex (math-wise and infrastructure -wise) currency ...
5
votes
2answers
9k views

Decimals in Apex: setting scale without rounding

Is there a possible way to set the scale of a decimal in Apex wihtout applying any rounding? (FI, the method setScale of Decimal object apply by default a half even rounding) Example: the following ...
11
votes
1answer
2k views

Converting between .NET decimal and SFDC decimal

We have a .NET app that interfaces with SFDC via a web service. When we import the WSDL the resulting classes will use the .NET type double wherever SFDC entities use a double. The problem I see here ...
7
votes
1answer
6k views

decimal places and text() formula

When I use the text formula, salesforce doesn't respect my decimal place formatting. For example, Field A has 4 places to the right of the decimal. It shows up nicely on the page as 0.4000 If I'm ...