Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Fun with real and float Rate Topic Display Mode Topic Options
Author
 Message
 Posted Monday, July 01, 2013 5:52 AM
 SSCertifiable Group: General Forum Members Last Login: Today @ 5:50 AM Points: 7,941, Visits: 8,360
 Hugo Kornelis (7/1/2013)[quote][b](By the way, I think real should be considered to have maximum precision six; you should always calculate with at least one more digit then the precision to limit the effect of rounding errors - at least, that's what has been taught to me in high school). Up that that point I thought your explanation was great, but here you are confusing the precision of representation with the accuracy or results. They aren't the same thing. Besides, your teachers were remiss in telling to use 1 rather than 2 or more - if you want final results accurate to N decimal places all starting values and intermediate results should be represented to a precision of at least N+2 decimal places unless the calculation to be carried out is utterly trivial. It's fine to work with N+1 places when the calculation is something rally very simple like a single multiplication, but if you are trying to compute the eigenvectors or the inverse of a 3 X 3 matrix (both calculations which are extremely common in elementary mechanics) working with N+1 places may give you horribly inaccurate results. 32bit floating point with precision 7 decimal places was intended to carry out complex calculations delivering results to a guaranteed 3 decimal places accuracy - an N+4 design rather than N+1 - and of course less complex calculations to greater guaranteed accuracy. The very earliest floating point hardware implementation (Zuse, 1941) was neither electronic nor part of a stored program computer and had much smaller precision (15 bits - so nominally decimal precision 3) and hence wasn't useful for any complex calculations unless a great lack of accuracy was acceptable. Tom'S iomadh doigh a th’ air cu a mharbhadh gun a thachdadh le ìme
Post #1469009
 Posted Monday, July 01, 2013 8:57 AM
 SSCrazy Group: General Forum Members Last Login: Today @ 8:33 AM Points: 2,218, Visits: 2,412
 Yes, thanks to Hugo for the detailed explanation. I agree with those who say that the Microsoft documentation could use Hugo's addition!I think the following queries show the switchover point where the REAL number is returned as 100.`-- Num1 = 99.99999CREATE TABLE #QotD ( Num1 REAL, Num2 FLOAT );INSERT INTO #QotDVALUES ( 99.9999961, 99.99999999997 );SELECT *FROM #QotD;DROP TABLE #QotD;``-- Num1 = 100CREATE TABLE #QotD ( Num1 REAL, Num2 FLOAT );INSERT INTO #QotDVALUES ( 99.9999962, 99.99999999997 );SELECT *FROM #QotD;DROP TABLE #QotD;`Thanks again.- webrunner -------------------"The chemistry must be respected." - Walter White"A SQL query walks into a bar and sees two tables. He walks up to them and says 'Can I join you?'"Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
Post #1469101
 Posted Monday, July 01, 2013 9:41 AM
 Hall of Fame Group: General Forum Members Last Login: Yesterday @ 4:56 PM Points: 3,912, Visits: 2,977
 L' Eomot Inversé (7/1/2013). . . The very earliest floating point hardware implementation (Zuse, 1941) was neither electronic nor part of a stored program computer and had much smaller precision (15 bits - so nominally decimal precision 3) and hence wasn't useful for any complex calculations unless a great lack of accuracy was acceptable.Z1 was built in 1936.http://en.wikipedia.org/wiki/Konrad_Zuse
Post #1469122
 Posted Monday, July 01, 2013 2:13 PM
 SSCertifiable Group: General Forum Members Last Login: Today @ 5:50 AM Points: 7,941, Visits: 8,360
 Revenant (7/1/2013)L' Eomot Inversé (7/1/2013). . . The very earliest floating point hardware implementation (Zuse, 1941) was neither electronic nor part of a stored program computer and had much smaller precision (15 bits - so nominally decimal precision 3) and hence wasn't useful for any complex calculations unless a great lack of accuracy was acceptable.Z1 was built in 1936.http://en.wikipedia.org/wiki/Konrad_ZuseI should have said "commercial hardware implementation" instead of just "hardware implementation" because I was excluding Z1 (as something that didn't really work, so not an implementation) and Z2 (as something which was only a prototype for the Z3 (and a demonstration machine for the German military), not a properly engineered machine. I don't regard the Z1 as an implementation (because it didn't often work, or so I was told).Although construction of the Z1 started in 1936, it didn't finish until 1938 and even when finished the machining of its parts wasn't clean/accurate enough so the machine frequently went wrong (or at least so I was taught long ago). There was no working Z1 until Siemens worked with Zuse to build one that actually worked (rather than reconstructing one that worked sometimes) in the late 1980s (a valuable history project, I think).The Z2 (finished in 1941) was another one-off prototype, with no future - it sprawled over too a large space and was very much a string and sealing-wax piece of engineering - in effect it was the testbed in which some of the Z3s design was verified. The first working machine, which actually went into production, was the Z3 (also 1941), and that was the machine I meant.Although it wasn't what we today call an electronic stored program computer, it had a significant electrical component (mechanical relays) and did store program in its electromechanical store. Zuse had patented pretty well all of what is known as Von Neumann architecture a few years before Williams and Kilburn started developing a reliable non-mechanical store for a stored-program computer which in turn was a year or two before Von Neumann wrote his report. In fact floating point was probably the one area (apart, of course, from politics) where Von Neumann disagreed with Zuse - he was famously anti-floating-point. Tom'S iomadh doigh a th’ air cu a mharbhadh gun a thachdadh le ìme
Post #1469213
 Posted Monday, July 01, 2013 2:18 PM
 Hall of Fame Group: General Forum Members Last Login: Yesterday @ 4:56 PM Points: 3,912, Visits: 2,977
 L' Eomot Inversé (7/1/2013)Revenant (7/1/2013)L' Eomot Inversé (7/1/2013). . . The very earliest floating point hardware implementation (Zuse, 1941) was neither electronic nor part of a stored program computer and had much smaller precision (15 bits - so nominally decimal precision 3) and hence wasn't useful for any complex calculations unless a great lack of accuracy was acceptable.Z1 was built in 1936.http://en.wikipedia.org/wiki/Konrad_ZuseI should have said "commercial hardware implementation" instead of just "hardware implementation" . . .Tom, as I said already several times, when you come to Redmond, or to the NW from Portland to Vancouver, we have to get together for drinks and I am buying.
Post #1469215
 Posted Monday, July 01, 2013 10:55 PM
 SSC-Addicted Group: General Forum Members Last Login: Friday, December 06, 2013 2:37 PM Points: 478, Visits: 238
 That's an easy one but worthwhile regarding the real and float data types. Thanks.
Post #1469286
 Posted Tuesday, July 02, 2013 12:46 AM
 SSChampion Group: General Forum Members Last Login: Today @ 7:31 AM Points: 11,209, Visits: 8,058
 Nice question, thanks. How to post forum questions.Need an answer? No, you need a question.What’s the deal with Excel & SSIS?Member of LinkedIn. My blog at LessThanDot. MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1469312
 Posted Tuesday, July 02, 2013 5:19 AM
 SSCertifiable Group: General Forum Members Last Login: Thursday, November 07, 2013 7:19 AM Points: 5,023, Visits: 1,363
 Nice one....
Post #1469403
 Posted Thursday, July 04, 2013 12:23 PM
 Old Hand Group: General Forum Members Last Login: Saturday, November 23, 2013 3:02 AM Points: 375, Visits: 88
 Very Nice Explanation
Post #1470496
 Posted Monday, July 08, 2013 5:23 AM
 Hall of Fame Group: General Forum Members Last Login: Today @ 6:52 AM Points: 3,319, Visits: 2,429
 Pretty simple question but what a good discussion. Some great explanation by Hugo.
Post #1471118

 Permissions