d2jsp
Log InRegister
d2jsp Forums > Off-Topic > General Chat > Homework Help > Numerical Computations Help
12Next
Add Reply New Topic New Poll
Member
Posts: 14,433
Joined: Oct 14 2013
Gold: Locked
Trader: Scammer
Sep 10 2015 05:24pm
THE IEEE half (16 bit) precision floating-point format uses 1 bit for the sign, 5 bits for the exponent, and 10 bits for the fraction.

1) estimate the overflow, underflow, and round-off values
2) Find the representation of pi.



Hi could anyone help me get started on this problem? I'm new to numerical computations and would appreciate a supplementary explanation of bits, underflow, overflow, round-off values.

Can pay FG for help if necessary.
Member
Posts: 14,433
Joined: Oct 14 2013
Gold: Locked
Trader: Scammer
Sep 11 2015 10:28pm
carteblanche, saber?

Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Sep 11 2015 10:39pm
i originally spent a fair bit of time showing some digits of pi step by step. then accidentally refreshed and lost it so i said fuggit. do you know how to convert a decimal number to binary floating point and just having problems with pi? or you dont know how to convert at all?

what don't you understand about bits?

iirc underflow is a value too small to represent and overflow is a value too large to represent. not sure what "estimate overflow value" means, unless it wants the first value too large to represent? round-off, i assume, refers to adding decimal values and getting an unexpected decimal result. like adding 1/3 + 1/3 + 1/3 and not getting 1.0, but not sure what the round-off "value" would be. it's been close to a decade since i studied IEEE format, and i dont really feel like googling the terms.

This post was edited by carteblanche on Sep 11 2015 10:43pm
Member
Posts: 14,433
Joined: Oct 14 2013
Gold: Locked
Trader: Scammer
Sep 12 2015 11:20am
i don't understand how bits relates to 1) and 2)

clearly we have to use the information given about the format of the precision floating-point of IEEE to answer 1) and 2) but that's all I know

This post was edited by Tamagochi on Sep 12 2015 11:20am
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Sep 12 2015 11:58am
Quote (Tamagochi @ Sep 12 2015 01:20pm)
i don't understand how bits relates to 1) and 2)

clearly we have to use the information given about the format of the precision floating-point of IEEE to answer 1) and 2) but that's all I know


do you know what the IEEE 16 bit floating format is? i'm not clear how you could accomplish either 1 or 2 without taking bits into account.



gonna copy a few examples from wiki:

Quote
0 01111 0000000000 = 1
0 01111 0000000001 = 1 + 2^−10 = 1.0009765625 (next smallest float after 1)
1 10000 0000000000 = −2

0 11110 1111111111 = 65504 (max half precision)

0 00001 0000000000 = 2^−14 ≈ 6.10352 × 10^−5 (minimum positive normal)
0 00000 1111111111 = 2^−14 - 2^−24 ≈ 6.09756 × 10^−5 (maximum subnormal)
0 00000 0000000001 = 2^−24 ≈ 5.96046 × 10^−8 (minimum positive subnormal)

0 00000 0000000000 = 0
1 00000 0000000000 = −0

0 11111 0000000000 = infinity
1 11111 0000000000 = −infinity

0 01101 0101010101 = 0.333251953125 ≈ 1/3


so for #2 you just represent pi best you can using these 16 bits

underflow/overflow depends completely on the bits. the bits allow you to represent quite a range of numbers, but the problem is not every number in the range can be represented.

This post was edited by carteblanche on Sep 12 2015 12:05pm
Member
Posts: 14,433
Joined: Oct 14 2013
Gold: Locked
Trader: Scammer
Sep 12 2015 02:24pm
0 01111 0000000000 = 1

could you explain this to me?
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Sep 12 2015 02:37pm
Quote (Tamagochi @ Sep 12 2015 04:24pm)
0 01111 0000000000 = 1

could you explain this to me?


short answer: 2^ (15 - 15) = 2^0 = 1

longer answer, look at the chart:

sign is 0, so it's positive.
look at the exponent now. exponent is 01111 = 15
look at the fractional component: 0000000000 = 0


so building the number:
2^(exponent - (2^(exponent bits - 1) - 1)) + fractional component
2^(exponent - (2^(5-1)-1)) + fractional component
2^(exponent - (2^4-1)) + fractional component
2^(exponent - 15) + fractional component
2^(15 - 15) + 0
= 2^0 + 0
= 1 + 0
= 1

it's easier to find tutorials for 32 bit floating points. 16 bit work the same way, just fewer bits



This post was edited by carteblanche on Sep 12 2015 02:59pm
Member
Posts: 14,433
Joined: Oct 14 2013
Gold: Locked
Trader: Scammer
Sep 13 2015 04:01pm
Ok thanks that helped me understand this a bit better.

I'm having trouble with this problem:

Write a Matlab function whose input is a positive number in base 10 and output is a string showing the number in base 12.
I think I get the idea of what needs to be done but I've only been using Matlab for a brief while so I would appreciate any help in starting the code.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Sep 13 2015 04:19pm
Quote (Tamagochi @ Sep 13 2015 06:01pm)
Ok thanks that helped me understand this a bit better.

I'm having trouble with this problem:

Write a Matlab function whose input is a positive number in base 10 and output is a string showing the number in base 12.
I think I get the idea of what needs to be done but I've only been using Matlab for a brief while so I would appreciate any help in starting the code.


i assume "positive number" means a 32 bit integer?

start with pseudo code to get your logic down, then convert the syntax to matlab.
Member
Posts: 14,433
Joined: Oct 14 2013
Gold: Locked
Trader: Scammer
Sep 13 2015 04:30pm
Quote (carteblanche @ Sep 13 2015 06:19pm)
i assume "positive number" means a 32 bit integer?

start with pseudo code to get your logic down, then convert the syntax to matlab.


not sure
Go Back To Homework Help Topic List
12Next
Add Reply New Topic New Poll