using System;
class Sample
{
public static void Main()
{
Console.WriteLine("(X) Hexadecimal:. . . . . . . {0:X}
" + -123, -123.45f);
}
}
Software Development
software development notes, main category for Cs, Java, and other programming experiences.
Use general format to output a float point value
using System;
class Sample
{
public static void Main()
{
Console.WriteLine("(G) General:. . . . . . . . . {0:G}
" + + -123, -123.45f);
}
}
Format float point value as fixed point
using System;
class Sample
{
public static void Main()
{
Console.WriteLine("(F) Fixed point:. . . . . . . {1:F}
" + -123, -123.45f);
}
}
Format float number as scientific notation
Output float number as currency
using System;
class Sample
{
public static void Main()
{
Console.WriteLine("(C) Currency: . . . . . . . . {0:C}
" + -123, -123.45f);
}
}
Format float as decimal
using System;
class Sample
{
public static void Main()
{
Console.WriteLine("(D) Decimal:. . . . . . . . . {0:D}
" + -123, -123.45f);
}
}
Using Floats
/*
* C# Programmers Pocket Consultant
* Author: Gregory S. MacBeth
* Email: gmacbeth@comporium.net
* Create Date: June 27, 2003
* Last Modified Date:
* Version: 1
*/
using System;
namespace Client.Chapter_1___Common_Type_System
{
public class UsingFloatsChapter_1___Common_Type_System {
static void Main(string[] args)
{
float MyFloat = 3.281f;
double MyDouble = 5E-02;
}
}
}