473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

why float [again]

System.Drawing.Drawing2D.Matrix comes in two flavors, int and float. When
doing graphics, you will you use float. Type double would be better, since
it is, when well applied, simply more acurate then float is. But things are
that there is no constructor for Matrix that accepts float.

But then, in the System.Math namespace, values like System.Math.PI and
function like Sin() and Cos() all return doubles. I can cast, of course, and
I do, but why?

Why float?

What is the reason there is a 'float' type in the first type, when you can
do all your floating point calculations with a double. CPU register size in
the hardware cannot be the reason since it is hardware specific.
Aug 4 '06 #1
6 1459
Hi,

I can't give you an answer why, but I guess there might be two reasons:
1. float is 32-bit vs double is 64-bit
2. Underlying GDI+ methods use 32-bit floating-point numbers.
--
Stoitcho Goutsev (100)
"Martijn Mulder" <i@mwrote in message
news:44***********************@news.wanadoo.nl...
System.Drawing.Drawing2D.Matrix comes in two flavors, int and float. When
doing graphics, you will you use float. Type double would be better, since
it is, when well applied, simply more acurate then float is. But things
are that there is no constructor for Matrix that accepts float.

But then, in the System.Math namespace, values like System.Math.PI and
function like Sin() and Cos() all return doubles. I can cast, of course,
and I do, but why?

Why float?

What is the reason there is a 'float' type in the first type, when you can
do all your floating point calculations with a double. CPU register size
in the hardware cannot be the reason since it is hardware specific.

Aug 4 '06 #2
That is why I have problems with float. Who cares about the bit-size of
floating numbers? Tomorrow float takes 512 bits and double takes 1024. And
the underlying GDI+ methods will take advantage of that

I can't give you an answer why, but I guess there might be two reasons:
1. float is 32-bit vs double is 64-bit
2. Underlying GDI+ methods use 32-bit floating-point numbers.
--
Stoitcho Goutsev (100)
"Martijn Mulder" <i@mwrote in message
news:44***********************@news.wanadoo.nl...
>System.Drawing.Drawing2D.Matrix comes in two flavors, int and float. When
doing graphics, you will you use float. Type double would be better,
since it is, when well applied, simply more acurate then float is. But
things are that there is no constructor for Matrix that accepts double.

But then, in the System.Math namespace, values like System.Math.PI and
function like Sin() and Cos() all return doubles. I can cast, of course,
and I do, but why?

Why float?

What is the reason there is a 'float' type in the first place, when you
can do all your floating point calculations with a double. CPU register
size in the hardware cannot be the reason since it is hardware specific.


Aug 5 '06 #3

"Martijn Mulder" <i@mwrote in message
news:44**********************@news.wanadoo.nl...
| That is why I have problems with float. Who cares about the bit-size of
| floating numbers? Tomorrow float takes 512 bits and double takes 1024. And
| the underlying GDI+ methods will take advantage of that
|

What makes you think that?
Tomorrow float will still be a 32 bit and a double still be 64 bit, and GDI+
(if it still exists) will still treat them as such.
Willy.
Aug 6 '06 #4
| That is why I have problems with float. Who cares about the bit-size of
| floating numbers? Tomorrow float takes 512 bits and double takes 1024.
And
| the underlying GDI+ methods will take advantage of that
|

What makes you think that?
Tomorrow float will still be a 32 bit and a double still be 64 bit, and
GDI+
(if it still exists) will still treat them as such.
Willy.
Why? Is it carved in stone that float is 32 bit an double 64 bit? It is just
what today's hardware can handle. Let us hope that GDI+ becomes better in
the future. Let us hope that it will be better than what it is now (it will.
I have no doubt about that). But in the foreseable future the register sizes
that we are accustumed to now wisill be laughable small
Aug 6 '06 #5
Martijn Mulder <i@mwrote:
What makes you think that?
Tomorrow float will still be a 32 bit and a double still be 64 bit, and
GDI+
(if it still exists) will still treat them as such.

Why? Is it carved in stone that float is 32 bit an double 64 bit?
It's carved in the specification.
It is just what today's hardware can handle.
No, it's in the specification, which people should be able to rely on.
The world has learned the lesson from the mess of C's decision to only
impose minimum requirements on types.
Let us hope that GDI+ becomes better in
the future. Let us hope that it will be better than what it is now (it will.
I have no doubt about that). But in the foreseable future the register sizes
that we are accustumed to now wisill be laughable small
Perhaps - in which case there will be extra types to cope with those.
If C# is still around, float will still be 32 bits and double will
still be 64 bits.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 7 '06 #6
What makes you think that?
Tomorrow float will still be a 32 bit and a double still be 64 bit, and
GDI+
(if it still exists) will still treat them as such.
>Why? Is it carved in stone that float is 32 bit an double 64 bit?
It's carved in the specification.
>It is just what today's hardware can handle.

No, it's in the specification, which people should be able to rely on.
The world has learned the lesson from the mess of C's decision to only
impose minimum requirements on types.
>Let us hope that GDI+ becomes better in
the future. Let us hope that it will be better than what it is now (it
will.
I have no doubt about that). But in the foreseable future the register
sizes
that we are accustumed to now wisill be laughable small

Perhaps - in which case there will be extra types to cope with those.
If C# is still around, float will still be 32 bits and double will
still be 64 bits.


Thank you
Aug 7 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Chris Beall | last post by:
See http://pages.prodigy.net/chris_beall/BeallSprings/WC.Deed%20GG.116-17.html using the CSS at http://pages.prodigy.net/chris_beall/BeallSprings/BSstyle.css The page is a transcript of a...
14
by: Glen Able | last post by:
Should it be possible to create a custom class, 'Float', which would behave as a drop-in replacement for the builtin float type? As mentioned in another thread, I once tried this in rather a...
54
by: Andy | last post by:
Hi, I don't know if this is the correct group to post this, but when I multiply a huge floating point value by a really small (non-zero) floating point value, I get 0 (zero) for the result. This...
26
by: 69dbb24b2db3daad932c457cccfd6 | last post by:
Hello, I have to initialize all elements of a very big float point array to zero. It seems memset(a, 0, len) is faster than a simple loop. I just want to know whether it is safe to do so, since I...
8
by: Kenny ODell | last post by:
I do not know how to convert from a byte array to a float, and back again. I read data from a serial port into a byte (entire command structure which I parse). I am able to sift the data and...
20
by: ehabaziz2001 | last post by:
That program does not yield and respond correctly espcially for the pointers (*f),(*i) in print_divide_meter_into(&meter,&yds,&ft,&ins); /*--------------pnt02own.c------------ ---1 inch = 2.51...
13
by: mishj | last post by:
Someone else on here had the same issue as I have but the response he got didnt solve my problem so I hope someone can help me (for some reason I was unable to reply on the same thread as the...
8
by: vjnr83 | last post by:
Hi, I have a doubt: what is the difference between float **p and float *p? Thanks in advance, Vijay
22
by: ashkaan57 | last post by:
Hi, I am trying to put text on left and right side of the page and used: <div> <span>blah blah</span> <span style="float:right">blah blah</span> </div> The 2nd text does go to the right but the...
7
by: DirtyRasa | last post by:
Here is what my professor told me to to. Write a function that converts a string to a float and returns a float. Test your function by entering f4 and with 4f. Both should say Data entered was...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.