floating-point-conversion

Are there any commonly used floating point formats besides IEEE754?

吃可爱长大的小学妹 提交于 2020-12-13 04:09:06
问题 I am writing a marshaling layer to automatically convert values between different domains. When it comes to floating point values this potentially means converting values from one floating point format to another. However, it seems that almost every modern system is using IEEE754, so I'm wondering whether it's actually worth generalising to allow other formats, or just manage marshaling between different IEEE754 formats. Does anyone know of any commonly used floating point formats other than

Are there any commonly used floating point formats besides IEEE754?

 ̄綄美尐妖づ 提交于 2020-12-13 04:08:00
问题 I am writing a marshaling layer to automatically convert values between different domains. When it comes to floating point values this potentially means converting values from one floating point format to another. However, it seems that almost every modern system is using IEEE754, so I'm wondering whether it's actually worth generalising to allow other formats, or just manage marshaling between different IEEE754 formats. Does anyone know of any commonly used floating point formats other than

How to convert a float string to an integer in python 3

喜夏-厌秋 提交于 2020-08-04 02:06:42
问题 I'm new to the whole coding thing...so here goes. Just trying to write a simple number guess game, but also do input validation. So that only integers are accepted as input. I've figured out how to weed out alphabetic characters, so I can convert the numbers into an integer. I'm having trouble when I put in a float number. I can't get it to convert the float number over to an integer. Any help is appreciated. As I said I'm on about day 3 of this coding thing so try to be understanding of my

How to convert a float string to an integer in python 3

情到浓时终转凉″ 提交于 2020-08-04 02:05:49
问题 I'm new to the whole coding thing...so here goes. Just trying to write a simple number guess game, but also do input validation. So that only integers are accepted as input. I've figured out how to weed out alphabetic characters, so I can convert the numbers into an integer. I'm having trouble when I put in a float number. I can't get it to convert the float number over to an integer. Any help is appreciated. As I said I'm on about day 3 of this coding thing so try to be understanding of my

Convert float to its binary representation (using MemoryStream?)

痞子三分冷 提交于 2020-02-02 02:27:23
问题 I'd like to convert a given float into its binary representation. I tried to write the float value into a MemoryStream , read this MemoryStream byte by byte and convert the bytes into their binary representation. But every attempt failed. "Can't read closed stream" (but I only closed the writer) For test purposes I simply wrote an integer (I think four bytes in size) and the length of the MemoryStream was 0, when I didn't flush the StreamWriter , and 1, when I did. I'm sure there is a better

Left shift Float type

只谈情不闲聊 提交于 2020-01-29 08:01:25
问题 get a complier error while trying to do float_val=float_val<<1; It gives out a error saying "error C2296: '<<' : illegal, left operand has type 'float '" Can't v left shift float vars? Why is this so? 回答1: You can't left shift float variables, because (a) your FPU generally will not have a barrel shifter exposed to you so physically cannot generate code to do that, and (b) what would it even mean? The underlying bit representation consists of multiple fields with different meanings, do you

Left shift Float type

放肆的年华 提交于 2020-01-29 08:01:13
问题 get a complier error while trying to do float_val=float_val<<1; It gives out a error saying "error C2296: '<<' : illegal, left operand has type 'float '" Can't v left shift float vars? Why is this so? 回答1: You can't left shift float variables, because (a) your FPU generally will not have a barrel shifter exposed to you so physically cannot generate code to do that, and (b) what would it even mean? The underlying bit representation consists of multiple fields with different meanings, do you

Left shift Float type

a 夏天 提交于 2020-01-29 08:00:41
问题 get a complier error while trying to do float_val=float_val<<1; It gives out a error saying "error C2296: '<<' : illegal, left operand has type 'float '" Can't v left shift float vars? Why is this so? 回答1: You can't left shift float variables, because (a) your FPU generally will not have a barrel shifter exposed to you so physically cannot generate code to do that, and (b) what would it even mean? The underlying bit representation consists of multiple fields with different meanings, do you

Bitwise Float To Int

若如初见. 提交于 2020-01-13 17:57:11
问题 I am trying to figure out the algorithm to this but all I get with google is doing it with casting. I need to know the details. So if we have a float x and want to return its binary representation what do we need to do? I know we need to return the float if its NaN or a infinity but otherwise what are the steps? EDIT The function takes in an unsigned int, to be used as if it was a float, and then return the integer the number represents. I cannot use casting, just conditionals and bit-wise