473,387 Members | 1,641 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,387 software developers and data experts.

32-bit IEEE float multiplication

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 creates a big hole in a 32-bit timer routine I wrote.

Questions.
1. Why does this happen?
2. Is there C macros/functions I can call to tell me
when two non-zero numbers are multiplied and the
result will be zero?

TIA
Andy
Nov 13 '05
54 8276
Andy wrote:
Dan.Pop wrote:
Sorry, but if you can't figure these things out yourself,
after all the advice you have received, you're in the wrong business.


Please stop wasting bandwidth with your senseless remarks.


I see that you've met some of our indigenous trolls.

Indigenous trolls live under bridges (usenet newsgroups)
and snack on unwary billy goats gruff (new subscribers).

http://www.surlalunefairytales.com/billygoats/

They try to provoke an emotional response from new subscribers
("get their goat" if you please ;-).
They may say nasty things about you, your intellect, your character
or even your mother that have nothing at all to do
with the topic of the comp.lang.c newsgroup.

The best way to deal with indigenous trolls is to ignore them.
Remember, if you respond, the troll wins. ;-)

Nov 14 '05 #51
In article <ae*************************@posting.google.com> bi*****@hotmail.com (Andy) writes:
Da*****@cern.ch (Dan Pop) wrote in message news:<br**********@sunnews.cern.ch>...
Sorry, but if you can't figure these things out yourself, after all the
advice you have received, you're in the wrong business.


Please stop wasting bandwidth with your senseless remarks.
If I understand you correctly, I would compare to the microseconds
counter if I need milliseconds resolution and I would compare
to the milliseconds counter if I need seconds resolution? But
ideally, I'd want a single counter to compare against for all
my timing needs from milliseconds, to seconds, to days. I guess
I can put these two counters in a struct, but then I'd have
a 64-bit timing variable. Too wastful..


Yup, that is life. As it is not clear at all what you really want, you
should not expect the people here to give you a clear solution.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Nov 14 '05 #52
E. Robert Tisdale wrote:
Andy wrote:
Dan.Pop wrote:
Sorry, but if you can't figure these things out yourself,
after all the advice you have received, you're in the wrong business.
Please stop wasting bandwidth with your senseless remarks.


I see that you've met some of our indigenous trolls.


Oh, don't be so ridiculous. Dan Pop is no troll. This is a case of the pot
calling the rainbow black.
The best way to deal with indigenous trolls is to ignore them.
To the OP: Tisdale's advice here, for once, is correct (insofar as it
suggests that you ignore his own articles). His advice is rarely topical
and rarely correct, so there's no point reading his stuff anyway.

Remember, if you respond, the troll wins. ;-)


No. This is a newsgroup, not a game. Where trolls like Tisdale are
concerned, nobody wins.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #53
In <ae*************************@posting.google.com> bi*****@hotmail.com (Andy) writes:
Da*****@cern.ch (Dan Pop) wrote in message news:<br**********@sunnews.cern.ch>...

Sorry, but if you can't figure these things out yourself, after all the
advice you have received, you're in the wrong business.
Please stop wasting bandwidth with your senseless remarks.


My remarks were far from senseless. They actually provided you with the
best solution for your problem. But if this is how you understand to say
"thank you", I may choose other ways of spending my time.
If I understand you correctly, I would compare to the microseconds
counter if I need milliseconds resolution and I would compare
to the milliseconds counter if I need seconds resolution? But
ideally, I'd want a single counter to compare against for all
my timing needs from milliseconds, to seconds, to days.
For an embedded control problem, the ideal solution is the one that
gets the job done in a minimum of CPU cycles and a minimum of program
memory bytes, not the one that minimizes the number of counters.
If you haven't understood that by now, reread my remark quoted at
the begining of this post.
I guess
I can put these two counters in a struct, but then I'd have
a 64-bit timing variable. Too wastful..


You need a 16-bit counter for microseconds, a 16-bit counter for
milliseconds and a 32-bit counter for seconds. There are only a few bits
wasted in the first two counters (which only use 10 bits out of 16).

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #54
Da*****@cern.ch (Dan Pop) wrote in message >
You need a 16-bit counter for microseconds, a 16-bit counter for
milliseconds and a 32-bit counter for seconds. There are only a few bits
wasted in the first two counters (which only use 10 bits out of 16).

Dan


After some soul searching, I've come up with this new clock
module (it only works for big-endian machines)
/* 4 millisecond increments */
#define GCLK_INC ((unsigned short)((double)(4.0) *
((double)65536.0/1000.0)) + 0.5)

/* use this type in your code */
typedef unsigned long GCLK_T;

/* Do not use this type in your code. It's only used internally in
gclk.c */
typedef union {
struct {
unsigned long secs;
unsigned short fractSecs; /* 1/65536 second */
} inc;
struct {
unsigned char unused;
GCLK_T ticks; /* upper 3 bytes are seconds. lower
byte 1/256 seconds */
} gclk;
} GCLK_LOW_LEVEL_T;

GCLK_LOW_LEVEL_T gcGClk;

#define GCLKIsr() do { \
gzGClk.inc.fractSecs += GCLK_INC; \
if (gzGClk.inc.fractSecs < GCLK_INC) { \
++gzGClk.inc.secs; \
} \
} while(0)

And everybody compares to gzGClk.gclk.ticks for time
references. that gives 24-bit seconds and 8-bit 1/65536 seconds.
This should work much better now. No? And the time measurement
should be linear up to overflow (in 198 days).

Andy
Nov 14 '05 #55

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

Similar topics

2
by: Mike Ruskai | last post by:
I've searched Google every way I know how, and came up with two answers that refer to MAX_KEY and MI_MAX_KEY, along with a typedef for key_map. I have the 4.1.1 alpha source (4.0 is no good,...
20
by: Ivar | last post by:
Hi, For my supprise I found that functions have 32 parameter limit. Where to find more info about this limitation or similar limitations ? I need at least 50, 100 would be ok. Real life...
5
by: Ian Rutherford | last post by:
Heya guys, It seems VB .net no longer supports the awesome ability of VB 6 to declare something as a string and specify how long the string would be all in one line: Public myString as String *...
6
by: barcaroller | last post by:
I couldn't find a message-digest newsgroup, so I posted here. I have a C function that converts a string of arbitrary length to a 32-bit hash value. I realize this is overkill but I used...
9
by: beni.cherniavsky | last post by:
Python seems to be missing a UCS-32 codec, even in wide builds (not that it the build should matter). Is there some deep reason or should I just contribute a patch? If it's just a bug, should I...
10
by: lesperancer | last post by:
you start with a small application in access97, then you have more modules and more... and you reach the point where tables like 'item' and 'employee' reach the limit and you know there's more...
3
by: Barry | last post by:
void func(int array) { for (int i = 0; i < 32; ++i) cout << array << ' '; } as the code above shows, I know int array here will decay into int *, but I still find the number 32 useful for...
2
by: Jeffrey Walton | last post by:
Hi All, BMP Strings are a subset of Universal Strings.The BMP string uses approximately 65,000 code points from Universal String encoding. BMP Strings: ISO/IEC 10646, 2-octet canonical form,...
6
by: docbook.xml | last post by:
I have the following in the XHTML 1.0 Strict page: <meta http-equiv="Content-Type" content="text/html;charset=utf-32" /> However W3 validator complains that "The character encoding specified in...
18
by: lak | last post by:
I am studying the Advanced programming in the unix environment. There they says that we can register upto 32 functions with atexit(). Why that is limited to 32 functions? can any one tell the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.