Skip to main content
Reduced capitalisation in title to aid readability
Link
Wai Ha Lee
  • 8.7k
  • 94
  • 59
  • 93

Best Wayway to get Whole Numberwhole number part of a Decimal Numbernumber

added tag
Link
Mark Carpenter
  • 17.6k
  • 23
  • 98
  • 151
made title more accurate, clarified situation.
Source Link
Yaakov Ellis
  • 41.2k
  • 27
  • 133
  • 177

Best Way to Get Intget Whole Number part of a Decimal Number

What is the best way to return the intwhole number part of a decimal (in c#)? (This has to work for very large numbers that may not fit into an int).

GetIntPart(343564564.4342) >> 343564564
GetIntPart(-323489.32) >> -323489
GetIntPart(324) >> 324

The purpose of this is: I am inserting into a decimal (30,4) field in the db, and want to ensure that I do not try to insert a number than is too long for the field. Determining the length of the whole number part of the decimal is part of this operation.

Best Way to Get Int part of a Decimal Number

What is the best way to return the int part of a decimal (in c#)?

GetIntPart(343564564.4342) >> 343564564
GetIntPart(-323489.32) >> -323489
GetIntPart(324) >> 324

Best Way to get Whole Number part of a Decimal Number

What is the best way to return the whole number part of a decimal (in c#)? (This has to work for very large numbers that may not fit into an int).

GetIntPart(343564564.4342) >> 343564564
GetIntPart(-323489.32) >> -323489
GetIntPart(324) >> 324

The purpose of this is: I am inserting into a decimal (30,4) field in the db, and want to ensure that I do not try to insert a number than is too long for the field. Determining the length of the whole number part of the decimal is part of this operation.

Source Link
Yaakov Ellis
  • 41.2k
  • 27
  • 133
  • 177
Loading