I'm trying to store the value 9234567891234567 in a Number Type SPListItem field. The underlying C# type for a Sharepoint Number Field is Double.
When I assign 9234567891234567 to a double C# var, then it holds 9234567891234568.
SPListItem items = list.GetItemById(siteID);
var value = Convert.ToDouble("9234567891234567");
//pb is that value holds 9234567891234568.0
items[fieldName] = value;
items.Update();
//just to check
double ret = (double) items[fieldName];
Console.WriteLine(ret.ToString("F"));
//outputs 9234567891234570.00
You will hate it, but the answer is "not at all".
https://support.office.com/en-us/article/Site-column-types-and-options-0d8ddb7b-7dc7-414d-a283-ee9dca891df7#__toc277149825
Let me quote:
lists the data types of sharepoint, and both numeric types (number, currency) are limited to 15 digits.
Which means you pretty much must store it as a string, with all the negative consequences that has. Sharepoint exposes a lot less functionality than a raw database, for example in not having large integer only data types.