Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

VB -> C#: Optimize Double(/Decimal)-to-Integer conversion

オープン
#1,020 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
csharp
領域
compilers

調査の方向性

提供された VB.NET 入力をオンラインコンバーターで再現し、その C# 出力を期待される出力と比較します。Double および Decimal 式に適用される CInt を処理する変換経路を追跡し、その後、冗長な Math.Round 呼び出しが削除される一方で、結果の変換が期待される動作を維持することを確認します。

索引モデルが issue の本文から書いたものです。

説明

enhancement
VB.Net input code
Imports System

Public Class A
    Public Shared Sub Main()
        Dim foo = 0.6
        Dim bar = CInt(Math.Truncate(foo))
        Dim baz = CInt(Math.Ceiling(foo))
        Console.WriteLine(bar)
        Console.WriteLine(baz)
    End Sub
End Class
Erroneous output
using System;

public partial class A
{
    public static void Main()
    {
        double foo = 0.6d;
        int bar = (int)Math.Round(Math.Truncate(foo));
        int baz = (int)Math.Round(Math.Ceiling(foo));
        Console.WriteLine(bar);
        Console.WriteLine(baz);
    }
}

Extra verbose Math.Round

Expected output
using System;

public partial class A
{
    public static void Main()
    {
        double foo = 0.6d;
        int bar = (int)foo;
        int baz = (int)Math.Ceiling(foo);
        Console.WriteLine(bar);
        Console.WriteLine(baz);
    }
}

Decimal is not optimized by the latest VB compiler but I think it can be.

CInt(Decimal) → System.Convert.ToInt32 (similar as (int)Math.Round)

Details
  • Product in use: online
  • Version in use: e.g. 5.6.3 or a commit hash (if it's a 3rd party tool using this library, try one of the above)
  • Did you see it working in a previous version, which? No
  • Any other relevant information to the issue, or your interest in contributing a fix.
主要言語
C#
スター
913
フォーク
244
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

icsharpcode/CodeConverter のほかの issue

icsharpcode/CodeConverter の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。