PC Review


Reply
Thread Tools Rate Thread

How can I convert Single to integer??

 
 
Yasin cepeci
Guest
Posts: n/a
 
      1st May 2007
How can I convert Single to integer??



 
Reply With Quote
 
 
 
 
zacks@construction-imaging.com
Guest
Posts: n/a
 
      1st May 2007
On May 1, 4:17 pm, "Yasin cepeci" <cep...@gmail.com> wrote:
> How can I convert Single to integer??


CInt() function maybe?

 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      1st May 2007
using System;
using System.Collections.Generic;
using System.Text;

namespace SingleToInt
{
class Program
{
static void Main(string[] args)
{
Single s = (Single)1111.87;
int i = (int)s;
Console.WriteLine(i);
Console.ReadLine();
}
}
}

--Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




"Yasin cepeci" wrote:

> How can I convert Single to integer??
>
>
>
>

 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      1st May 2007
Yasin cepeci <(E-Mail Removed)> wrote:
> How can I convert Single to integer??


Just cast:

float f = 15.56f;

int x = (int) f;

Be aware that the range of float is much larger than the range of int,
however...

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Point and Size in Single instead of Integer C Microsoft VB .NET 3 8th Aug 2010 01:18 AM
Convert integer to bit cmdolcet69 Microsoft VB .NET 4 31st Aug 2008 12:01 AM
how can i subtract single integer value from the entire column =?Utf-8?B?bmFnYSBzIGNoaW50YWxh?= Microsoft Excel Charting 5 1st May 2005 01:38 AM
Single more 'powerful' than Integer although both use same amount of bytes ??? Chris Microsoft C# .NET 2 15th Nov 2003 10:44 PM
Single more 'powerful' than Integer although both use same amount of bytes ??? Chris Microsoft VB .NET 2 15th Nov 2003 06:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:33 PM.