Hi guys,
I use LUTs to accelerate certain parts of my app. The LUTs contain
float numbers, and I generated the numbers very precisely, up to 10
decimals. All seems fine, however, when I printf the numbers in the
LUT, I do not get the same exact numbers. The first 6 decimals are ok,
but it got beserk after that. To illustrate further:
float myLUT = [0.123456789, 0.123456789, 0.123456789, ............... .] ;
printf("myLUT: .10f", myLUT[1]);
##### output
myLUT: 0.123456111
I am not quite sure why that is the case, although I believe float do
not have enough precision, so the compiler (VC 8) gives the closest
approximation that can be had with float. Is that so? Can somebody
enlighten me on that issue?
Thanks in advance,
Enrique 6 2494
Enrique Cruiz <jn************ *@jetable.orgwr ites:
I use LUTs to accelerate certain parts of my app. The LUTs contain
float numbers, and I generated the numbers very precisely, up to 10
decimals. All seems fine, however, when I printf the numbers in the
LUT, I do not get the same exact numbers. The first 6 decimals are ok,
but it got beserk after that. To illustrate further:
float myLUT = [0.123456789, 0.123456789, 0.123456789, ............... .] ;
float is only guaranteed to have 6 decimal digits worth of
accuracy. If you need more, use double, which has at least 10
decimal digits worth of accuracy. Also, read what the C FAQ has
to say about floating point numbers.
--
Peter Seebach on C99:
"[F]or the most part, features were added, not removed. This sounds
great until you try to carry a full-sized printout of the standard
around for a day."
Enrique Cruiz <jn************ *@jetable.orgwr ites:
I use LUTs to accelerate certain parts of my app. The LUTs contain
float numbers, and I generated the numbers very precisely, up to 10
decimals. All seems fine, however, when I printf the numbers in the
LUT, I do not get the same exact numbers. The first 6 decimals are ok,
but it got beserk after that. To illustrate further:
float myLUT = [0.123456789, 0.123456789, 0.123456789, ............... .] ;
printf("myLUT: .10f", myLUT[1]);
What the heck is a "LUT", and what language are you using? ("LookUp
Table", maybe?) The above is a syntax error in C, even if you replace
the ".............. .." with something meaningful. It's probably some
compiler-specific extension.
Aside from that, type float just doesn't provide the precision you
need. Type double or long double might. Consult your system's
documentation.
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
On Mar 15, 5:18 pm, Enrique Cruiz <jni6l03mdo6n.. .@jetable.orgwr ote:
Hi guys,
I use LUTs to accelerate certain parts of my app. The LUTs contain
float numbers, and I generated the numbers very precisely, up to 10
decimals. All seems fine, however, when I printf the numbers in the
LUT, I do not get the same exact numbers. The first 6 decimals are ok,
but it got beserk after that. To illustrate further:
float myLUT = [0.123456789, 0.123456789, 0.123456789, ............... .] ;
printf("myLUT: .10f", myLUT[1]);
##### output
myLUT: 0.123456111
I am not quite sure why that is the case, although I believe float do
not have enough precision,
Why? Float is only guaranteed to have 6 digits of precision, which
is exactly what you are seeing.
If you need more than 6 digits of precision, then, use double
(And unless you have a reason to use float, use double).
Why do you think you need this precision? (Are you trying
to check the results using the LUT against those not
using a LUT?)
Have you checked to see if using the LUT actually does
increase execution speed? (It is quite possible for
the opposite to happen). Have you checked whether
the putative incease in speed is significant?
- William Hughes
Enrique Cruiz wrote:
>
I use LUTs to accelerate certain parts of my app. The LUTs contain
float numbers, and I generated the numbers very precisely, up to 10
decimals. All seems fine, however, when I printf the numbers in the
LUT, I do not get the same exact numbers. The first 6 decimals are
ok, but it got beserk after that. To illustrate further:
float myLUT = [0.123456789, 0.123456789, 0.123456789, ..........] ;
printf("myLUT: .10f", myLUT[1]);
##### output
myLUT: 0.123456111
I am not quite sure why that is the case, although I believe float
do not have enough precision, so the compiler (VC 8) gives the
closest approximation that can be had with float. Is that so? Can
somebody enlighten me on that issue?
Look in <float.hfor the number of digits available. Consider
using double rather than float.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>
mm
--
Posted via a free Usenet account from http://www.teranews.com
William Hughes wrote:
>
.... snip ...
>
Have you checked to see if using the LUT actually does increase
execution speed? (It is quite possible for the opposite to
happen). Have you checked whether the putative incease in speed
is significant?
What is a LUT? A capitalized abbreviation for a lute, perhaps. If
so, who is playing it.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net>
--
Posted via a free Usenet account from http://www.teranews.com
CBFalconer <cb********@yah oo.comwrites:
What is a LUT?
Look-Up Table.
--
"I should killfile you where you stand, worthless human." --Kaz This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: George Hester |
last post by:
At the time this suggestion was made I didn't have the wherewithall to even attempt it. But over time I learned enough to make a stab at it. Let just say the foating DIV had to provide the same advantages as a chromeless window else it really wouldn''t help.
You see the idea is that the chromeless window forces a client to make a choice. It cannot be closed until a choice is made. If the user decides not to allow the chromeless window to...
|
by: JHR |
last post by:
Hey all,
I'm trying to make a sidebar box float to the right of various items,
and for those items to wrap if a user shrinks his browser window.
Instead, in every browser I've tried except for Internet Explorer (in
Safari, Firefox, and other Mozilla-types), the box ends up overlapping
with the second and third rows of the text (which are in an ordered list
with some 'display: table-cell' formats defined in order to allow
specific...
|
by: meltedown |
last post by:
I would like the floating divs to float and then the header to come
after them , on the left. That's what I thought clearing the floats was
for, but in this example, the header is to the right of the floating
divs, nothing is cleared. What am I doing wrong ?
Here is the url:http://www.reenie.org/test/test5.php
Here is the code:
<html>
<head>
|
by: buliwyf_23 |
last post by:
I have this:
CSize sz;
sz.cx = dwOutX1;
sz.cy = dwOutY1;
CPoint pt(sz);
ClientToScreen(&pt);
|
by: Usenet |
last post by:
I might be being silly here.
On my links page I've got a whole load of floating boxes, which I'm
really pleased with.
But then I want the footer to be *below* them.
On my current site (http://www.vowleyfarm.co.uk/CommunityLinks.htm)
I've cheated by putting the footer in a floating box as well, but now
I'm moving to using a CMS I would like not to hack my page template
in this way.
| |
by: hendrakieran |
last post by:
Hi Guys,
I'd like to get some help regarding creating a floating window with the following scenario:
* I have index.html which is contains the frameset definition:
<html>
<head>
</head>
|
by: Qiang |
last post by:
Those who have used Google notebook may notice that google notebook
displays the notes in a small floating window of the browser. I have
tried to create a similar floating window, but with no luck. Dojo has a
sample floating window, but that floating window has to exist in a
browser page, but looks like Google's floating window can exist
independently.
I also tried to debug the google notebook javascript code. It has two
compressed...
|
by: gdrenfrew |
last post by:
I'd like to know if it is possible to stop the parent application of a floating form becoming active when the controls on the floating form are clicked?
I've got a large application, with multiple embedded controls. Some of the controls can be detached on effectively floating forms, which can be dragged about the screen. Not using MDI type stuff, just forms.
The app is on our traders' desktops, and they have many applications open...
|
by: murali.desikan |
last post by:
Hi,
The definition of floating literal in the C++ (ISO/IEC 14882:2003)
grammar is as follows (Note: I have replaced the "opt" subscript used
in the standard with to indicate optional symbol).
------BEGIN------
floating-literal:
fractional-constant
digit-sequence exponent-part
|
by: Jeremy |
last post by:
I've got a floating div which becomes visible when a link is clicked. I
want the div to be hidden when the user clicks anywhere on the page except
for whithin the div. What is the best way to do this? Really, I only need
to support ie6+ but cross browser is always nice.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |