Skip to main content
deleted 2426 characters in body
Source Link
user1228
user1228

By the way guys, (int)Decimal.MaxValue will overflow. You can't get the "int" part of a decimal because the decimal is too friggen big to put in the int box. Just checked... its even too big for a long (Int64).

If you want the bit of a Decimal value to the LEFT of the dot, you need to do this:

Math.Truncate(number)

and return the value as... A DECIMAL or a DOUBLE.

edit: Truncate is definitely the correct function!


Noldorin is annoyed that I changed my answer. Let me be clear here--it was Jon's comment to this question that prompted me to change my answer. I gave him credit in the comments for doing so. I have also upvoted every answer in this question that was correct. I did not select the answer, Yaakov did. I did not vote up my question, SO members did.

Here's a friendly guide to getting rep from answers.

  1. Answer quickly. Fastest gun rules. You'll see high rep people here post an initial answer, only to come back and modify it if needed. If you don't like that, you don't like SO.

  2. The more content you provide the more upvotes you get. While anyone posting a correct answer -- Math.Truncate -- should get upvotes, how do you pick one to be the answer? Often its chosen by upvote total (see 1). But if you provide more information than just the answer, you tend to get more upvotes. Note how I was clear about why the question was flawed--you get overflows when casting a Decimal to an int. That's an incredibly important piece of information that every developer needs to know--an unchecked build would result in hard to track down bugs that this overflow would cause. Its that extra information that helps, And people tend to upvote answers that contain that extra info.

  3. If your answer is wrong, fix it. Wrong answers help nobody. The fact is that when I changed my answer, I was already the highest voted answer in here. I could have just left it; it was an acceptable answer, but not the best answer. So after I read Jon's comment I did some reading on the Truncate function. It did, of course, everything that needed to be done here. So I responded to his comment, saying he was right, and updated my answer, marking it as edited. If I'm a scumbag for changing a wrong answer to a right answer and giving credit where credit is due, then I'm a scumbag. But I'm not going to let an incorrect answer stand if I can help it.


The final word

Sup revision readers. Got a flag on this answer (that I provided well before becoming a mod) pointing out that the whole thing is a mess. I have to agree. I'm editing to add this note and to record the comments here, so at least this information is preserved in the revision history.

The comments from this post, before they were removed

By the way guys, (int)Decimal.MaxValue will overflow. You can't get the "int" part of a decimal because the decimal is too friggen big to put in the int box. Just checked... its even too big for a long (Int64).

If you want the bit of a Decimal value to the LEFT of the dot, you need to do this:

Math.Truncate(number)

and return the value as... A DECIMAL or a DOUBLE.

edit: Truncate is definitely the correct function!


Noldorin is annoyed that I changed my answer. Let me be clear here--it was Jon's comment to this question that prompted me to change my answer. I gave him credit in the comments for doing so. I have also upvoted every answer in this question that was correct. I did not select the answer, Yaakov did. I did not vote up my question, SO members did.

Here's a friendly guide to getting rep from answers.

  1. Answer quickly. Fastest gun rules. You'll see high rep people here post an initial answer, only to come back and modify it if needed. If you don't like that, you don't like SO.

  2. The more content you provide the more upvotes you get. While anyone posting a correct answer -- Math.Truncate -- should get upvotes, how do you pick one to be the answer? Often its chosen by upvote total (see 1). But if you provide more information than just the answer, you tend to get more upvotes. Note how I was clear about why the question was flawed--you get overflows when casting a Decimal to an int. That's an incredibly important piece of information that every developer needs to know--an unchecked build would result in hard to track down bugs that this overflow would cause. Its that extra information that helps, And people tend to upvote answers that contain that extra info.

  3. If your answer is wrong, fix it. Wrong answers help nobody. The fact is that when I changed my answer, I was already the highest voted answer in here. I could have just left it; it was an acceptable answer, but not the best answer. So after I read Jon's comment I did some reading on the Truncate function. It did, of course, everything that needed to be done here. So I responded to his comment, saying he was right, and updated my answer, marking it as edited. If I'm a scumbag for changing a wrong answer to a right answer and giving credit where credit is due, then I'm a scumbag. But I'm not going to let an incorrect answer stand if I can help it.


The final word

Sup revision readers. Got a flag on this answer (that I provided well before becoming a mod) pointing out that the whole thing is a mess. I have to agree. I'm editing to add this note and to record the comments here, so at least this information is preserved in the revision history.

The comments from this post, before they were removed

By the way guys, (int)Decimal.MaxValue will overflow. You can't get the "int" part of a decimal because the decimal is too friggen big to put in the int box. Just checked... its even too big for a long (Int64).

If you want the bit of a Decimal value to the LEFT of the dot, you need to do this:

Math.Truncate(number)

and return the value as... A DECIMAL or a DOUBLE.

edit: Truncate is definitely the correct function!

added 437 characters in body
Source Link
user1228
user1228

By the way guys, (int)Decimal.MaxValue will overflow. You can't get the "int" part of a decimal because the decimal is too friggen big to put in the int box. Just checked... its even too big for a long (Int64).

If you want the bit of a Decimal value to the LEFT of the dot, you need to do this:

Math.Truncate(number)

and return the value as... A DECIMAL or a DOUBLE.

edit: Truncate is definitely the correct function!


Noldorin is annoyed that I changed my answer. Let me be clear here--it was Jon's comment to this question that prompted me to change my answer. I gave him credit in the comments for doing so. I have also upvoted every answer in this question that was correct. I did not select the answer, Yaakov did. I did not vote up my question, SO members did.

Here's a friendly guide to getting rep from answers.

  1. Answer quickly. Fastest gun rules. You'll see high rep people here post an initial answer, only to come back and modify it if needed. If you don't like that, you don't like SO.

  2. The more content you provide the more upvotes you get. While anyone posting a correct answer -- Math.Truncate -- should get upvotes, how do you pick one to be the answer? Often its chosen by upvote total (see 1). But if you provide more information than just the answer, you tend to get more upvotes. Note how I was clear about why the question was flawed--you get overflows when casting a Decimal to an int. That's an incredibly important piece of information that every developer needs to know--an unchecked build would result in hard to track down bugs that this overflow would cause. Its that extra information that helps, And people tend to upvote answers that contain that extra info.

  3. If your answer is wrong, fix it. Wrong answers help nobody. The fact is that when I changed my answer, I was already the highest voted answer in here. I could have just left it; it was an acceptable answer, but not the best answer. So after I read Jon's comment I did some reading on the Truncate function. It did, of course, everything that needed to be done here. So I responded to his comment, saying he was right, and updated my answer, marking it as edited. If I'm a scumbag for changing a wrong answer to a right answer and giving credit where credit is due, then I'm a scumbag. But I'm not going to let an incorrect answer stand if I can help it.


The final word

Sup revision readers. Got a flag on this answer (that I provided well before becoming a mod) pointing out that the whole thing is a mess. I have to agree. I'm editing to add this note and to record the comments here, so at least this information is preserved in the revision history.

The comments from this post, before they were removed

By the way guys, (int)Decimal.MaxValue will overflow. You can't get the "int" part of a decimal because the decimal is too friggen big to put in the int box. Just checked... its even too big for a long (Int64).

If you want the bit of a Decimal value to the LEFT of the dot, you need to do this:

Math.Truncate(number)

and return the value as... A DECIMAL or a DOUBLE.

edit: Truncate is definitely the correct function!


Noldorin is annoyed that I changed my answer. Let me be clear here--it was Jon's comment to this question that prompted me to change my answer. I gave him credit in the comments for doing so. I have also upvoted every answer in this question that was correct. I did not select the answer, Yaakov did. I did not vote up my question, SO members did.

Here's a friendly guide to getting rep from answers.

  1. Answer quickly. Fastest gun rules. You'll see high rep people here post an initial answer, only to come back and modify it if needed. If you don't like that, you don't like SO.

  2. The more content you provide the more upvotes you get. While anyone posting a correct answer -- Math.Truncate -- should get upvotes, how do you pick one to be the answer? Often its chosen by upvote total (see 1). But if you provide more information than just the answer, you tend to get more upvotes. Note how I was clear about why the question was flawed--you get overflows when casting a Decimal to an int. That's an incredibly important piece of information that every developer needs to know--an unchecked build would result in hard to track down bugs that this overflow would cause. Its that extra information that helps, And people tend to upvote answers that contain that extra info.

  3. If your answer is wrong, fix it. Wrong answers help nobody. The fact is that when I changed my answer, I was already the highest voted answer in here. I could have just left it; it was an acceptable answer, but not the best answer. So after I read Jon's comment I did some reading on the Truncate function. It did, of course, everything that needed to be done here. So I responded to his comment, saying he was right, and updated my answer, marking it as edited. If I'm a scumbag for changing a wrong answer to a right answer and giving credit where credit is due, then I'm a scumbag. But I'm not going to let an incorrect answer stand if I can help it.

By the way guys, (int)Decimal.MaxValue will overflow. You can't get the "int" part of a decimal because the decimal is too friggen big to put in the int box. Just checked... its even too big for a long (Int64).

If you want the bit of a Decimal value to the LEFT of the dot, you need to do this:

Math.Truncate(number)

and return the value as... A DECIMAL or a DOUBLE.

edit: Truncate is definitely the correct function!


Noldorin is annoyed that I changed my answer. Let me be clear here--it was Jon's comment to this question that prompted me to change my answer. I gave him credit in the comments for doing so. I have also upvoted every answer in this question that was correct. I did not select the answer, Yaakov did. I did not vote up my question, SO members did.

Here's a friendly guide to getting rep from answers.

  1. Answer quickly. Fastest gun rules. You'll see high rep people here post an initial answer, only to come back and modify it if needed. If you don't like that, you don't like SO.

  2. The more content you provide the more upvotes you get. While anyone posting a correct answer -- Math.Truncate -- should get upvotes, how do you pick one to be the answer? Often its chosen by upvote total (see 1). But if you provide more information than just the answer, you tend to get more upvotes. Note how I was clear about why the question was flawed--you get overflows when casting a Decimal to an int. That's an incredibly important piece of information that every developer needs to know--an unchecked build would result in hard to track down bugs that this overflow would cause. Its that extra information that helps, And people tend to upvote answers that contain that extra info.

  3. If your answer is wrong, fix it. Wrong answers help nobody. The fact is that when I changed my answer, I was already the highest voted answer in here. I could have just left it; it was an acceptable answer, but not the best answer. So after I read Jon's comment I did some reading on the Truncate function. It did, of course, everything that needed to be done here. So I responded to his comment, saying he was right, and updated my answer, marking it as edited. If I'm a scumbag for changing a wrong answer to a right answer and giving credit where credit is due, then I'm a scumbag. But I'm not going to let an incorrect answer stand if I can help it.


The final word

Sup revision readers. Got a flag on this answer (that I provided well before becoming a mod) pointing out that the whole thing is a mess. I have to agree. I'm editing to add this note and to record the comments here, so at least this information is preserved in the revision history.

The comments from this post, before they were removed

added 2013 characters in body
Source Link
user1228
user1228

By the way guys, (int)Decimal.MaxValue will overflow. You can't get the "int" part of a decimal because the decimal is too friggen big to put in the int box. Just checked... its even too big for a long (Int64).

If you want the bit of a Decimal value to the LEFT of the dot, you need to do this:

Math.Truncate(number)

and return the value as... A DECIMAL or a DOUBLE.

edit: Truncate is definitely the correct function!


Noldorin is annoyed that I changed my answer. Let me be clear here--it was Jon's comment to this question that prompted me to change my answer. I gave him credit in the comments for doing so. I have also upvoted every answer in this question that was correct. I did not select the answer, Yaakov did. I did not vote up my question, SO members did.

Here's a friendly guide to getting rep from answers.

  1. Answer quickly. Fastest gun rules. You'll see high rep people here post an initial answer, only to come back and modify it if needed. If you don't like that, you don't like SO.

  2. The more content you provide the more upvotes you get. While anyone posting a correct answer -- Math.Truncate -- should get upvotes, how do you pick one to be the answer? Often its chosen by upvote total (see 1). But if you provide more information than just the answer, you tend to get more upvotes. Note how I was clear about why the question was flawed--you get overflows when casting a Decimal to an int. That's an incredibly important piece of information that every developer needs to know--an unchecked build would result in hard to track down bugs that this overflow would cause. Its that extra information that helps, And people tend to upvote answers that contain that extra info.

  3. If your answer is wrong, fix it. Wrong answers help nobody. The fact is that when I changed my answer, I was already the highest voted answer in here. I could have just left it; it was an acceptable answer, but not the best answer. So after I read Jon's comment I did some reading on the Truncate function. It did, of course, everything that needed to be done here. So I responded to his comment, saying he was right, and updated my answer, marking it as edited. If I'm a scumbag for changing a wrong answer to a right answer and giving credit where credit is due, then I'm a scumbag. But I'm not going to let an incorrect answer stand if I can help it.

By the way guys, (int)Decimal.MaxValue will overflow. You can't get the "int" part of a decimal because the decimal is too friggen big to put in the int box. Just checked... its even too big for a long (Int64).

If you want the bit of a Decimal value to the LEFT of the dot, you need to do this:

Math.Truncate(number)

and return the value as... A DECIMAL or a DOUBLE.

edit: Truncate is definitely the correct function!

By the way guys, (int)Decimal.MaxValue will overflow. You can't get the "int" part of a decimal because the decimal is too friggen big to put in the int box. Just checked... its even too big for a long (Int64).

If you want the bit of a Decimal value to the LEFT of the dot, you need to do this:

Math.Truncate(number)

and return the value as... A DECIMAL or a DOUBLE.

edit: Truncate is definitely the correct function!


Noldorin is annoyed that I changed my answer. Let me be clear here--it was Jon's comment to this question that prompted me to change my answer. I gave him credit in the comments for doing so. I have also upvoted every answer in this question that was correct. I did not select the answer, Yaakov did. I did not vote up my question, SO members did.

Here's a friendly guide to getting rep from answers.

  1. Answer quickly. Fastest gun rules. You'll see high rep people here post an initial answer, only to come back and modify it if needed. If you don't like that, you don't like SO.

  2. The more content you provide the more upvotes you get. While anyone posting a correct answer -- Math.Truncate -- should get upvotes, how do you pick one to be the answer? Often its chosen by upvote total (see 1). But if you provide more information than just the answer, you tend to get more upvotes. Note how I was clear about why the question was flawed--you get overflows when casting a Decimal to an int. That's an incredibly important piece of information that every developer needs to know--an unchecked build would result in hard to track down bugs that this overflow would cause. Its that extra information that helps, And people tend to upvote answers that contain that extra info.

  3. If your answer is wrong, fix it. Wrong answers help nobody. The fact is that when I changed my answer, I was already the highest voted answer in here. I could have just left it; it was an acceptable answer, but not the best answer. So after I read Jon's comment I did some reading on the Truncate function. It did, of course, everything that needed to be done here. So I responded to his comment, saying he was right, and updated my answer, marking it as edited. If I'm a scumbag for changing a wrong answer to a right answer and giving credit where credit is due, then I'm a scumbag. But I'm not going to let an incorrect answer stand if I can help it.

deleted 22 characters in body
Source Link
user1228
user1228
Loading
added 349 characters in body
Source Link
user1228
user1228
Loading
HURRRR
Source Link
user1228
user1228
Loading
Source Link
user1228
user1228
Loading