Go to Post After this trip, a person might want to change their underpants. - Andy Baker [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #7   Spotlight this post!  
Unread 08-02-2009, 19:40
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: New class for Logitech Dual Action Gamepad

Quote:
Originally Posted by Phazonmutant View Post
In general, you're absolutely right. But in this case, I've done pretty extensive testing (outputting the raw axis value to the console), and the gamepad will always output -1 or 1.

Edit 1: You'll notice the article is talking about testing floats when doing floating point math. Since we're doing no math, only testing a returned value, it's safe.
Edit 2: Furthermore, it talks about how the binary representation is not 100% precise for some numbers. The binary representation of floating points is implementation-specific, but lets assume the first bit is for the sign, the next 24 bits are for the significant figures, and the last 7 bits are for the base (IEEE 754 defines 24 bits as standard for 32-bit - single precision - floating point numbers). OK, a d1 (a 1 in decimal) looks like:
Code:
11000000000000000000000000000000
or, a 1 for the sign, a "100000000000000000000000" (a 1 followed by 23 0s) for the significant figures, and 7 0s (base = 0).
This is precisely 1.
We're using a Logitech gamepad that outputs analog values on the D-Pad. The buttons under the dpad on that stick are pressure sensitive and CAN output a value less than 1 if you press them lightly. And, most people follow the "don't test an exact value of a float" as a rule-of-thumb (so as not to get into trouble) rather than considering the exact implementation and whether it's safe for a particular case. We tend to write code with portability in mind, even if we're not likely to port it, just as a good habit to have.
Reply With Quote
 


Thread Tools
Display Modes 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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
define a new class(C++) nadavsen2 C/C++ 15 02-11-2010 13:21
pic: 716 Dual Motor/Dual Speed CD47-Bot Robot Showcase 18 23-04-2004 01:51
White Paper Discuss: Dual-motor, dual-speed gearbox CD47-Bot Extra Discussion 8 05-04-2004 19:24
White Paper Discuss: Dual-motor, dual-speed drive transmission design CD47-Bot Extra Discussion 9 03-09-2003 10:40
Gamepad Controller Mike375 Technical Discussion 13 05-03-2002 21:20


All times are GMT -5. The time now is 15:29.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi