• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 00:55
CET 06:55
KST 14:55
  • 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
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
ComeBackTV's documentary on Byun's Career !9Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win4Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump1Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15
StarCraft 2
General
Micro Lags When Playing SC2? ComeBackTV's documentary on Byun's Career ! When will we find out if there are more tournament Weekly Cups (Dec 8-14): MaxPax, Clem, Cure win RSL Revival - 2025 Season Finals Preview
Tourneys
$100 Prize Pool - Winter Warp Gate Masters Showdow $5,000+ WardiTV 2025 Championship Winter Warp Gate Amateur Showdown #1 Sparkling Tuna Cup - Weekly Open Tournament RSL Offline Finals Info - Dec 13 and 14!
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 504 Retribution Mutation # 503 Fowl Play Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress
Brood War
General
Klaucher discontinued / in-game color settings Anyone remember me from 2000s Bnet EAST server? BGH Auto Balance -> http://bghmmr.eu/ How Rain Became ProGamer in Just 3 Months FlaSh on: Biggest Problem With SnOw's Playstyle
Tourneys
[BSL21] LB QuarterFinals - Sunday 21:00 CET Small VOD Thread 2.0 [Megathread] Daily Proleagues [BSL21] WB SEMIFINALS - Saturday 21:00 CET
Strategy
Simple Questions, Simple Answers Game Theory for Starcraft Current Meta Fighting Spirit mining rates
Other Games
General Games
Stormgate/Frost Giant Megathread General RTS Discussion Thread Nintendo Switch Thread Mechabellum PC Games Sales Thread
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
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas Survivor II: The Amazon Sengoku Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine The Games Industry And ATVI YouTube Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
TL+ Announced Where to ask questions and add stream?
Blogs
The (Hidden) Drug Problem in…
TrAiDoS
I decided to write a webnov…
DjKniteX
James Bond movies ranking - pa…
Topin
Thanks for the RSL
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1844 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
Ladder Legends
19:00
WWG Amateur Showdown
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft654
RuFF_SC2 217
Nina 115
StarCraft: Brood War
Larva 575
Shuttle 478
Leta 273
Mong 18
Noble 15
Sea 0
Dota 2
NeuroSwarm90
LuMiX1
League of Legends
JimRising 650
Heroes of the Storm
Khaldor141
Other Games
summit1g10090
Mew2King102
ViBE59
Models2
Organizations
Other Games
gamesdonequick856
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 12 non-featured ]
StarCraft 2
• Berry_CruncH211
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Other Games
• Scarra1628
Upcoming Events
Sparkling Tuna Cup
4h 5m
Ladder Legends
11h 5m
BSL 21
14h 5m
StRyKeR vs TBD
Bonyth vs TBD
Replay Cast
1d 3h
Wardi Open
1d 6h
Monday Night Weeklies
1d 11h
WardiTV Invitational
3 days
Replay Cast
4 days
WardiTV Invitational
4 days
ByuN vs Solar
Clem vs Classic
Cure vs herO
Reynor vs MaxPax
Replay Cast
5 days
Liquipedia Results

Completed

Acropolis #4 - TS3
RSL Offline Finals
Kuram Kup

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
Slon Tour Season 2
CSL Season 19: Qualifier 1
WardiTV 2025
META Madness #9
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22

Upcoming

CSL Season 19: Qualifier 2
CSL 2025 WINTER (S19)
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Big Gabe Cup #3
OSC Championship Season 13
Nations Cup 2026
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
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.