Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

Difference between Math.Floor() and Math.Truncate()

// Math.Floor rounds down
// Math.Ceiling rounds up
// Math.Truncate rounds towards zero

Round(1.5) = 2
Round(2.5) = 2
Round(1.5, MidpointRounding.AwayFromZero) = 2
Round(2.5, MidpointRounding.AwayFromZero) = 3
Round(1.55, 1) = 1.6
Round(1.65, 1) = 1.6
Round(1.55, 1, MidpointRounding.AwayFromZero) = 1.6
Round(1.65, 1, MidpointRounding.AwayFromZero) = 1.7

Truncate(2.10) = 2
Truncate(2.00) = 2
Truncate(1.90) = 1
Truncate(1.80) = 1
Comment

PREVIOUS NEXT
Code Example
Csharp :: Nested objects with linq expression 
Csharp :: how to use javascriptexecutor for loop in selenium c# 
Csharp :: how can datetimepicker accept hour as well 
Csharp :: c# Search specified string inside textbox 
Csharp :: vb.net how insert event inside an event 
Csharp :: translate nicely between two vector3 
Csharp :: dotnet.com 
Csharp :: how to get image from resource folder in c# 
Csharp :: is it possible to be palindrome 
Csharp :: c# datagridview count value 
Csharp :: access audio source from gameobject unity 
Csharp :: unity c# rate game 
Csharp :: assetfinder 
Csharp :: build a project from dotnet using cli 
Csharp :: asp net core send email async 
Csharp :: what does - in f#? 
Csharp :: stackpanel opacity mask from resources wpf 
Csharp :: how to remove black top bar in asp.net 
Csharp :: generate random string 
Html :: ssss 
Html :: leading spaces html 
Html :: tag for tel 
Html :: registered symbol html 
Html :: bootstrap col-md-5 center 
Html :: how to link your js file to html 
Html :: bootstrap 5 font weight 
Html :: regex to remove html tags python 
Html :: v-select item-text function 
Html :: auto update copyright year javascript 
Html :: set icon for html page tab 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =