c++ - behavior of float-point conversion to integer -


i've fixed-length integer class , know how implement conversion type native float-point , vice verse there special cases don't know do:

suppose signed type name t , unsigned version ut, type size 128-bit

(1) native float-point value greater/smaller t or ut can represent?

(2) value of t or ut greater/smaller native float-point can represent?

should truncate, throw exception or set result zero?

thank you.

from question i'm not sure understand floating point. floating point representations have both magnitude , precision, question talking magnitude. although integer within range representable floating point still may not accurately representable floating point. care loss of accuracy?

my choice throw exception, include methods check beforehand whether 1 number representable in other format. give user of code choice of how want handle special cases in other words.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -