Hi
I have below code cast(ZZ.U_No_of_Box as numeric(19,0)) and value is displayed as 19.00.
I want only 19. Decimal part should not be printed
Thanks
Hi
I have below code cast(ZZ.U_No_of_Box as numeric(19,0)) and value is displayed as 19.00.
I want only 19. Decimal part should not be printed
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sam HobbsRank #107 · 20.5K reputationPosted Nov 11, 2023, 9:11 PM EST
The documentation of the double struct is at:
Double Struct (System) | Microsoft Learn
https://learn.microsoft.com/en-us/dotnet/api/system.double?view=net-7.0
There are Floor and Round static methods. When you use a cast, and when you use the Flour method, the decimal portion is discarded. The Round method will round (up or down). The following:
Code Snippet
public static void Main() { Show(19.03); Show(19.97); } public static void Show(double data) { Console.WriteLine($"Data: {data}; Cast: {(Int32)data}; floor: {double.Floor(data)}; round: {double.Round(data)}"); }Produces:
Data: 19.03; Cast: 19; floor: 19; round: 19
Data: 19.97; Cast: 19; floor: 19; round: 20
Note that Round works differently than the others.
Khoday AkileshRank #638 · 3.8K reputationPosted Nov 11, 2023, 12:07 AM EST
double data = 19.03; Console.WriteLine("Converted from {0}, to {1}", data, (Int32)data);