Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8457909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:56:03+00:00 2026-06-10T12:56:03+00:00

Module Module1 Public Sub Main() Dim values() As Double = {43.523, 12.65, 43.565} For

  • 0
Module Module1
Public Sub Main()
    Dim values() As Double = {43.523, 12.65, 43.565}
    For Each value As Double In values
        Console.WriteLine("{0} --> {1}", value, Math.Round(value, 2))
    Next
    Console.ReadLine()
End Sub
End Module

The above code results as

  • 43.523 –> 43.52

  • 12.65 –> 12.65

  • 43.565 –> 43.56

I need 43.565 –> 43.57 and not 43.565 –> 43.56.
But i still need the other 43.523 –> 43.52 and 12.65 –> 12.65 rounded as is.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:56:05+00:00Added an answer on June 10, 2026 at 12:56 pm

    Firstly, if exact decimal values are of concern to you, you should consider using Decimal instead of Double. In particular, 43.565 isn’t exactly representable as a Double to start with.

    However, if you want to specify the behaviour for “midpoints” (i.e. where it could reasonably round up or down), use the overload with a MidpointRounding parameter:

    Console.WriteLine("{0} --> {1}", value, _
                      Math.Round(value, 2, MidpointRounding.AwayFromZero))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Reproduction: Imports System.ComponentModel Imports System.ComponentModel.DataAnnotations Module Module1 Sub Main() Dim type = GetType(Contact) TypeDescriptor.AddProviderTransparent(
Module Module1 Public cccounter = 9 End Module Public Class frmNim Private Sub btnSelect_Click(sender
I have application with this code: Module Startup <STAThread()> _ Public Sub Main() Try
Here's my current Macro Public Module CopyrightCode Sub AddCopyrightHeader() Dim doc As Document Dim
Imports System.Reflection Public Class Test Private Field As String End Class Module Module1 Sub
I have a program like this. Module Module1 Public Class Mstr Public Property Prop1
Module Module1 Public Declare Function GET_CALCULATION_FAN_ALONE Lib EbmPapstFan.dll (ByRef path As String) As Long
this action is generated in symfony 1.2 when you create a module: public function
When I add a public function to a standard code module in Excel it
I have a method in a url rewriting module that looks like this public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.