Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > float

Reply
Thread Tools

float

 
 
Christopher
Guest
Posts: n/a
 
      10-27-2011
On Oct 18, 7:34*am, SG <s.gesem...@gmail.com> wrote:
> On 18 Okt., 01:55, Paul wrote:
>
> > Ian Collins wrote in message
> > > [...] ramtin wrote:

>
> > >> int main(array<System::String ^> *^args)

>
> > > This looks like a language almost, but not entirely, unlike C++.

>
> > That is the syntax use din MSVC++ when you create a windows form
> > projec(C++), probably a .net thing.

>
> I would guess that a large fraction of the competent regulars
> (including Ian) already know exactly what it is: C++/CLI. And yes,
> that's what you get if you ask Herb Sutter to make .NET easily
> accessible from C++ by use of language extensions.
>
> Off-topic: I makes me chuckle a bit to see almost the same syntax
> being used for C++/CX where the CX language extensions are used to
> deal with WinRT's ref-counting object system. I guess Microsoft lost a
> bit of interest in .NET and C++/CLI since this seems to make the CLI
> and CX extensions mutually exclusive. Btw, I can recommend Herb
> Sutter's "modern C++" talk. It almost sounds like he's trying to
> convert .NET developers. "Look, how easy it is to write modern and
> safe C++ code!".
>
> Cheers!
> SG


I never really understood what advantage there would be in using C++/
CLI. If I want CLI, why wouldn't I just use C# instead? Maybe so I can
have pointers? OT anyway I suppose.
 
Reply With Quote
 
 
 
 
Dombo
Guest
Posts: n/a
 
      10-28-2011
Op 27-Oct-11 23:29, Christopher schreef:
> On Oct 18, 7:34 am, SG<s.gesem...@gmail.com> wrote:
>> On 18 Okt., 01:55, Paul wrote:
>>
>>> Ian Collins wrote in message
>>>> [...] ramtin wrote:

>>
>>>>> int main(array<System::String ^> ^args)

>>
>>>> This looks like a language almost, but not entirely, unlike C++.

>>
>>> That is the syntax use din MSVC++ when you create a windows form
>>> projec(C++), probably a .net thing.

>>
>> I would guess that a large fraction of the competent regulars
>> (including Ian) already know exactly what it is: C++/CLI. And yes,
>> that's what you get if you ask Herb Sutter to make .NET easily
>> accessible from C++ by use of language extensions.
>>
>> Off-topic: I makes me chuckle a bit to see almost the same syntax
>> being used for C++/CX where the CX language extensions are used to
>> deal with WinRT's ref-counting object system. I guess Microsoft lost a
>> bit of interest in .NET and C++/CLI since this seems to make the CLI
>> and CX extensions mutually exclusive. Btw, I can recommend Herb
>> Sutter's "modern C++" talk. It almost sounds like he's trying to
>> convert .NET developers. "Look, how easy it is to write modern and
>> safe C++ code!".
>>
>> Cheers!
>> SG

>
> I never really understood what advantage there would be in using C++/
> CLI. If I want CLI, why wouldn't I just use C# instead?


+1
 
Reply With Quote
 
 
 
 
88888 Dihedral
Guest
Posts: n/a
 
      10-29-2011
float d1= 4/3 ; /* promote to inetger only in the right hand side result */

float d2= 4.0/3 ; /* promote to float */
float d3= 4/3.0 ;
float d4= 4.0/3.0;
 
Reply With Quote
 
red floyd
Guest
Posts: n/a
 
      10-29-2011
On 10/28/2011 9:06 PM, 88888 Dihedral wrote:
> float d1= 4/3 ; /* promote to inetger only in the right hand side result */

No, that's integer arithmetic, result promoted to float.

>
> float d2= 4.0/3 ; /* promote to float */
> float d3= 4/3.0 ;
> float d4= 4.0/3.0;


Technically, the first two are promote to double, truncate to float.
The third is already double, truncate to float.
 
Reply With Quote
 
88888 Dihedral
Guest
Posts: n/a
 
      10-29-2011


red floyd於 2011年10月29日星期*UTC+8下午1時14分07 寫道:
> On 10/28/2011 9:06 PM, 88888 Dihedral wrote:
> > float d1= 4/3 ; /* promote to inetger only in the right hand side result */

> No, that's integer arithmetic, result promoted to float.
>
> >
> > float d2= 4.0/3 ; /* promote to float */
> > float d3= 4/3.0 ;
> > float d4= 4.0/3.0;

>
> Technically, the first two are promote to double, truncate to float.
> The third is already double, truncate to float.

------------------------------------------------------
int x=3;
int y=4;

float d = x/y ;
float d= ((float)x)/y ;

/* whether the compiler knows x,y are constants up to now ? */

 
Reply With Quote
 
red floyd
Guest
Posts: n/a
 
      10-29-2011
On 10/28/2011 11:27 PM, 88888 Dihedral wrote:
>
>
> red floyd於 2011年10月29日星期*UTC+8下午1時14分07 寫道:
>> On 10/28/2011 9:06 PM, 88888 Dihedral wrote:
>>> float d1= 4/3 ; /* promote to inetger only in the right hand side result */

>> No, that's integer arithmetic, result promoted to float.
>>
>>>
>>> float d2= 4.0/3 ; /* promote to float */
>>> float d3= 4/3.0 ;
>>> float d4= 4.0/3.0;

>>
>> Technically, the first two are promote to double, truncate to float.
>> The third is already double, truncate to float.

> ------------------------------------------------------
> int x=3;
> int y=4;
>
> float d = x/y ;
> float d= ((float)x)/y ;
>
> /* whether the compiler knows x,y are constants up to now ? */
>


What's your point? 4.0 and 3.0 are *DOUBLE* constants.

 
Reply With Quote
 
ptyxs
Guest
Posts: n/a
 
      10-30-2011
Is there any compelling reason to use float instead of double ? If
not, use double.
 
Reply With Quote
 
Ian Collins
Guest
Posts: n/a
 
      10-30-2011
On 10/30/11 09:40 PM, ptyxs wrote:
> Is there any compelling reason to use float instead of double ? If
> not, use double.


Is there any compelling reason not to include any context in your post?

--
Ian Collins
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
float to string to float, with first float == second float Carsten Fuchs C++ 45 10-08-2009 09:47 AM
operator== (float, float) Jukka Lehtonen C++ 5 08-05-2004 08:28 AM
need code to convert float format to internal java float format which is kept in 4 bytes integer Andy Java 7 05-10-2004 09:26 PM
static_cast<float>(a) versus float(a) Jim West C++ 4 01-16-2004 12:36 PM
Re: float->byte->float is same with original float image. why float->ubyte->float is different??? bd C Programming 0 07-07-2003 12:09 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57