{"id":1358,"date":"2025-02-14T14:06:23","date_gmt":"2025-02-14T14:06:23","guid":{"rendered":"https:\/\/ibex.tech\/csharp\/?p=1358"},"modified":"2025-10-31T11:00:35","modified_gmt":"2025-10-31T11:00:35","slug":"rounding","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/c-sharp\/maths\/rounding","title":{"rendered":"Rounding"},"content":{"rendered":"\n<p>Using this<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\tint MyIntValue;\n\tfloat MyFloatValue = 1.53;\n\tMyIntValue = Convert::ToInt32(MyFloatValue);<\/code><\/pre>\n\n\n\n<p>Will result in MyIntValue = 2, because Convert::ToInt rounds to the nearest value. To force rounding down use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\tMyIntValue = (int)Math.Floor(MyFloatValue);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Using this Will result in MyIntValue = 2, because Convert::ToInt rounds to the nearest value. To force rounding down use:<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[157],"tags":[],"class_list":["post-1358","post","type-post","status-publish","format-standard","hentry","category-maths"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=1358"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1358\/revisions"}],"predecessor-version":[{"id":1420,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/1358\/revisions\/1420"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=1358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=1358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=1358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}