![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm used to programming in c or c++ in which my problem is simple. I want to be able to enter a value on a page (like 3.2), and then read it as a 32-bit float and break it into it's individual bytes. I've tried using bitwise operators, but they seem to convert the value into an integer first, and i've tried using the toString() method to convert it into a hex value so i can parse it, but that also seems to first convert it into an integer. any help would be much appreciated. |
#3
| |||
| |||
|
|
TK wrote on 03 jun 2005 in comp.lang.javascript: I'm used to programming in c or c++ in which my problem is simple. I want to be able to enter a value on a page (like 3.2), and then read it as a 32-bit float and break it into it's individual bytes. I've tried using bitwise operators, but they seem to convert the value into an integer first, and i've tried using the toString() method to convert it into a hex value so i can parse it, but that also seems to first convert it into an integer. any help would be much appreciated. Please look at the very explicit source of: http://babbage.cs.qc.edu/courses/cs3...-754hex32.html and all will be revealed to you. |
#4
| |||
| |||
|
|
Evertjan. wrote: TK wrote on 03 jun 2005 in comp.lang.javascript: I'm used to programming in c or c++ in which my problem is simple. I want to be able to enter a value on a page (like 3.2), and then read it as a 32-bit float and break it into it's individual bytes. I've tried using bitwise operators, but they seem to convert the value into an integer first, and i've tried using the toString() method to convert it into a hex value so i can parse it, but that also seems to first convert it into an integer. any help would be much appreciated. Please look at the very explicit source of: http://babbage.cs.qc.edu/courses/cs3...-754hex32.html and all will be revealed to you. that appears to do a lot more than I need. Is there a simpler way? |
|
All I need is to be able to input a value like 3.2 on screen, and display each byte seperatly as 0x40 0x4C 0xCC 0xCC. |
#5
| |||
| |||
|
|
All I need is to be able to input a value like 3.2 on screen, and display each byte seperatly as 0x40 0x4C 0xCC 0xCC. |
#6
| ||||
| ||||
|
|
I want to be able to enter a value on a page (like 3.2), and then read it as a 32-bit float and break it into it's individual bytes. |
|
I've tried using bitwise operators, but they seem to convert the value into an integer first |
|
i've tried using the toString() method to convert it into a hex value so i can parse it, but that also seems to first convert it into an integer. |
|
any help would be much appreciated. |
#7
| |||
| |||
|
|
All numbers are represented internally as 64-bit, double-precision values, according to IEEE 754. No built-in operators or functions will provide you with direct access to this representation. |
#8
| |||
| |||
|
|
All I need is to be able to input a value like 3.2 on screen, and display each byte seperatly as 0x40 0x4C 0xCC 0xCC. Impossible, because that format only supports integers, and a definition of what you compoundly want is not clear. What would those bytes represent, if not a complicated as on the babbage site above? |
#9
| |||
| |||
|
|
I'm used to programming in c or c++ in which my problem is simple. I want to be able to enter a value on a page (like 3.2), and then read it as a 32-bit float and break it into it's individual bytes. I've tried using bitwise operators, but they seem to convert the value into an integer first, and i've tried using the toString() method to convert it into a hex value so i can parse it, but that also seems to first convert it into an integer. |
#10
| |||
| |||
|
|
"TK" <tok135 (AT) hotmail (DOT) com> skrev i meddelandet news:11a16ssabnave7d (AT) corp (DOT) supernews.com... snip All I need is to be able to input a value like 3.2 on screen, and display each byte seperatly as 0x40 0x4C 0xCC 0xCC. What if the native byte order is different on the machine? What if float/fixed implementations vary on different platforms? |
![]() |
| Thread Tools | |
| Display Modes | |
| |