C#
  Home arrow C# arrow Numbers
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C#

Numbers
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 19
    2004-06-29

    Table of Contents:
  • Numbers
  • Determining Approximate Equality Between a Fraction and Floating-Point Value
  • Converting Degrees to Radians and Converting Radians to Degrees
  • Using the Bitwise Complement Operator with Various Data Types
  • Test for an Even or Odd Value
  • Converting a Number in Another Base to Base10 and Determining Whether a String Is a Valid Number
  • Determining Whether a String Is a Valid Number
  • Rounding a Floating-Point Value and Different Rounding Algorithms Problem
  • Converting Celsius to Fahrenheit and
  • Safely Performing a Narrowing Numeric Cast
  • Discussion
  • Finding the Length of Any Three Sides of a Right Triangle and Finding the Angles of a Right Triangle Problem

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!

    Numbers


    (Page 1 of 12 )

    Items in this chapter from C# Cookbook (O'Reilly Media, ISBN: 0-596-00339-0, 2004) include: Testing for even or odd vlaue, safely performing a narrowing numeric cast and converting radians to degrees. Get a complete, documented code sample to solve a specific problem, and review a discussion of how the underlying technology works, alternatives and limitations.

    TeilhetSimple types are value types that are a subset of the built-in types in Visual C# .NET, although, in fact, the types are defined as part of the .NET Framework Class Library (.NET FCL).

     Simple types are made up of several numeric types and a bool type. These numeric types consist of a decimal type (decimal), nine integral types (byte, char, int, long, sbyte, short, uint, ulong, ushort), and two floating-point types (float, double).

    Table 1-1 lists the simple types and their fully qualified names in the .NET Framework.

    Table 1-1. The simple data types

    Fully qualified nameReserved C# keywordValue Range
    System.Booleanbooltrue or false
    System.Bytebyte0 to 255
    System.BSBytesbyte-128 to 127
    System.Charchar0 to 65535
    System.Decimaldecimal–79,228,162,514,264,337,593,543,950,335 to 79,228,162,514,264,337,593,543,950,335
    System.Doubledouble–1.79769313486232e308 to 1.79769313486232e308
    System.Singlefloat–3.402823e38 to 3.402823e38
    System.Int16short–32768 to 32767
    System.Uint16ushort0 to 65535
    System.Int32int–2,147,483,648 to 2,147,483,647
    System.Uint32uint0 to 4,294,967,295
    System.Int64long–9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
    System.Uint64ulong0 to 18,446,744,073,709,551,615

    The C# reserved words for the various data types are simply aliases for the fully qualified type name. Therefore, it does not matter whether you use the type name or the reserved word: the C# compiler will generate identical code.

    It should be noted that the following types are not CLS-compliant: sbyte, ushort, uint, and ulong. These types do not conform to the rules governing CLS types and therefore, they might not be supported by other .NET languages. This lack of support might limit or impede the interaction between your C# code and code written in another CLS-compliant language, such as Visual Basic .NET. 

    Buy the book!If you've enjoyed what you've seen here, or to get more information, click on the "Buy the book!" graphic. Pick up a copy today!

    Visit the O'Reilly Network http://www.oreillynet.com for more online content.

    More C# Articles
    More By O'Reilly Media


     

    C# ARTICLES

    - Exceptions in C#
    - Overriding versus Overloading
    - Value Types and Reference Types
    - Defining Member and Type Visibility
    - Managing Files in C#
    - Working with Windows Registry in C#
    - Lossless Image Resizing in C#
    - Lossless Image Converting in C#
    - Creating an RSS Feed with ASP.Net Written in...
    - Polymorphism in C#
    - Inheritance in C#
    - C# Events Explained
    - C# Delegates Explained
    - C# StreamReader and StreamWriter Explained
    - C# FileStream Explained

    Iron Speed




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway