• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 03:00
CEST 09:00
KST 16:00
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Flash Announces Hiatus From ASL61Weekly Cups (June 23-29): Reynor in world title form?13FEL Cracov 2025 (July 27) - $8000 live event20Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
Statistics for vetoed/disliked maps Program: SC2 / XSplit / OBS Scene Switcher The SCII GOAT: A statistical Evaluation Weekly Cups (June 23-29): Reynor in world title form? PiG Sty Festival #5: Playoffs Preview + Groups Recap
Tourneys
FEL Cracov 2025 (July 27) - $8000 live event RSL: Revival, a new crowdfunded tournament series Korean Starcraft League Week 77 Master Swan Open (Global Bronze-Master 2) [GSL 2025] Code S: Season 2 - Semi Finals & Finals
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Flash Announces Hiatus From ASL Player “Jedi” cheat on CSL ASL20 Preliminary Maps SC uni coach streams logging into betting site BGH Mineral Boosts Tutorial Video
Tourneys
[BSL20] Grand Finals - Sunday 20:00 CET [Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Path of Exile Stormgate/Frost Giant Megathread Nintendo Switch Thread What do you want from future RTS games? Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Trading/Investing Thread Things Aren’t Peaceful in Palestine The Games Industry And ATVI
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2025 Football Thread Formula 1 Discussion NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 527 users

Ah! Floating point help!!

Blogs > Raithed
Post a Reply
Raithed
Profile Blog Joined May 2007
China7078 Posts
Last Edited: 2007-11-14 03:42:28
November 14 2007 03:42 GMT
#1
anyone have ideas on floating points? i missed class today and found out i had homework. i googled floating points and read through it, and i dont quite understand it. even though the homework gives answer, i want to know how the answer is derived from it?

3.14 for example.

the floating point would be 3? i know how to convert that to binary, and that to hex, but i have no idea how floating point works, someone give me a clue?


something like this, thats one of the sites the homework gave. http://babbage.cs.qc.edu/IEEE-754/Decimal.html but i want to know how it works.

"convert 3.14159265 to 32bit FP"


Help?!

Meta
Profile Blog Joined June 2003
United States6225 Posts
November 14 2007 04:51 GMT
#2
umm i was in the understanding that floating point numbers are numbers with decimal places. the float of 3.14 is 3.14. if you convert that to an integer, then you'd get 3. i'm not sure how to convert floating points into binary/hex though.
good vibes only
HeadBangaa
Profile Blog Joined July 2004
United States6512 Posts
Last Edited: 2007-11-14 05:51:01
November 14 2007 05:07 GMT
#3
Floating point numbers are stored in a special way in binary. The implementation is dependent on the CPU, but the most common is IEEE 754. Your class is probably only gonna make you handle single-precision floats, which are 32-bits in length.

Oooh, I found this for ya. Really good:
http://en.wikipedia.org/wiki/IEEE_754

Skip to the "Single Precision" section and start reading.
Do some sample problems using the algorithm detailed there. Use this website to cross-check your answers:
http://www.h-schmidt.net/FloatApplet/IEEE754.html

Once you get the bit representation, you convert to hex/octal/whatever in the usual way.
Also, most FP numbers can't be represented in just 32-bits, so the rounding of the mantissa is conventionally performed (this is why you get rounding-warnings from your compiler when you're not careful with numerical types/casts).
People who fail to distinguish Socratic Method from malicious trolling are sadly stupid and not worth a response.
Raithed
Profile Blog Joined May 2007
China7078 Posts
November 14 2007 05:36 GMT
#4
Oh man, this is intense, INTENSE, alrighty. >_<
HeadBangaa
Profile Blog Joined July 2004
United States6512 Posts
Last Edited: 2007-11-14 07:26:59
November 14 2007 07:22 GMT
#5
Per PM request:

OK, so there's 3 sections:

The (s)ign = 1-bit
THe (e)xponent = 8-bits
The (m)antissa = 23-bits

total = 32-bits

v = 3.14159265
where:
v = s * 2^e * m

OK, let's rock:

-The sign bit is easy: 0 (because positive number)
-Now write out the number in UNSIGNED, NON-TWOS COMPLEMENT:
11.001001xxxx


The "11." part is easy; it's just '3' in binary, and the decimal sign tagged on the end.
FOr the righthand part, I use the result in each step for 2 things:
a) the MSB of the result is the next-bit you write down
b) the fraction of the result (behind the decimal) is used in the next step.

Start with original number's fractional part:

0.14159265 x 2 = 0.2831853 (fraction-bit #1 = 0)
0.2831853 x 2 = 0.5663706 (fraction-bit #2 = 0)
0.5663706 x 2 = 1.1327412 ("" = 1)
0.1327412 x 2 = 0.2654824 ("" = 0)
0.2654824 x 2 = 0.5309648 ("" = 0)
0.5309648 x 2 = 1.0619296 ("" = 1)
(keep going until you get all zeros in the decimal, or until you've populated 23-bits).


And that's how I get: .001001xxxx (tediously 23-bits long, you finish it) and together, we have 11.001001xxxx

Now you "normalize" your result by moving the decimal such that only a single "1" is to its left:
11.001001xxxx = 1.1001001xxxx * 2^1 (shift amount = 1)

OK, now add the bias to the shift-amount:
1 + 127 = 128 = 10000000

Now mash everything together:
[s][exponent][mantissa] = 1 10000000 1001001xxxx

ba-zing!
People who fail to distinguish Socratic Method from malicious trolling are sadly stupid and not worth a response.
liosama
Profile Blog Joined October 2007
Australia843 Posts
November 21 2007 00:11 GMT
#6
haha i remeber FP conversions back when i did microcontrollers, learning the conversion is the kind of thing you learn once before the exam, then forget for the rest of your life
Free Palestine
Raithed
Profile Blog Joined May 2007
China7078 Posts
November 21 2007 05:32 GMT
#7
Yeah! We're using them for microcontrollers/MP's.
Please log in or register to reply.
Live Events Refresh
Next event in 3h
[ Submit Event ]
Live Streams
Refresh
StarCraft: Brood War
Leta 594
Larva 324
Barracks 53
Dota 2
XaKoH 617
League of Legends
JimRising 745
Counter-Strike
Stewie2K1060
Heroes of the Storm
Khaldor237
Other Games
WinterStarcraft694
SortOf101
kaitlyn73
ProTech55
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 17 non-featured ]
StarCraft 2
• Berry_CruncH361
• Hupsaiya 92
• Sammyuel 41
• Kozan
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• intothetv
• Migwel
• IndyKCrew
StarCraft: Brood War
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• lizZardDota2168
League of Legends
• Lourlo1348
• masondota2816
• Stunt496
Upcoming Events
RSL Revival
3h
Clem vs Classic
SHIN vs Cure
FEL
5h
WardiTV European League
5h
BSL: ProLeague
11h
Dewalt vs Bonyth
Replay Cast
1d 17h
Sparkling Tuna Cup
2 days
WardiTV European League
2 days
The PondCast
3 days
Replay Cast
3 days
RSL Revival
4 days
[ Show More ]
Replay Cast
4 days
RSL Revival
5 days
FEL
5 days
RSL Revival
6 days
FEL
6 days
FEL
6 days
Liquipedia Results

Completed

BSL 2v2 Season 3
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.