Skip to main content
Rollback to Revision 1
Source Link

EDIT

I quickly checked the result with the result given here but now I see that I did not scroll till the end. It seems that the code in the answer return the 'non-normalized' binary representation (that page b.t.w. very explicitly provides the recipe for how to obtain the 32-bit IEEE 754 representation and this page for the 64-bit version).

I will leave the answer here anyway.

END EDIT

You can't. Emacs Lisp is a highly abstract, strongly typed dynamic language where everything is a reference. It determines the data type through the highest bits of pointers in C language. If you want to treat a floating point number as an integer, you have to modify some bits of the pointer. This can't be done in Emacs Lisp; you must modify it through a debugger like GDB.

But you can write a function to find out the precise representation of a floating point number. As per the elisp manual, Emacs Lisp follows IEEE-754.

EDIT

I quickly checked the result with the result given here but now I see that I did not scroll till the end. It seems that the code in the answer return the 'non-normalized' binary representation (that page b.t.w. very explicitly provides the recipe for how to obtain the 32-bit IEEE 754 representation and this page for the 64-bit version).

I will leave the answer here anyway.

END EDIT

You can't. Emacs Lisp is a highly abstract, strongly typed dynamic language where everything is a reference. It determines the data type through the highest bits of pointers in C language. If you want to treat a floating point number as an integer, you have to modify some bits of the pointer. This can't be done in Emacs Lisp; you must modify it through a debugger like GDB.

But you can write a function to find out the precise representation of a floating point number. As per the elisp manual, Emacs Lisp follows IEEE-754.

You can't. Emacs Lisp is a highly abstract, strongly typed dynamic language where everything is a reference. It determines the data type through the highest bits of pointers in C language. If you want to treat a floating point number as an integer, you have to modify some bits of the pointer. This can't be done in Emacs Lisp; you must modify it through a debugger like GDB.

But you can write a function to find out the precise representation of a floating point number. As per the elisp manual, Emacs Lisp follows IEEE-754.

added 753 characters in body
Source Link

EDIT

I quickly checked the result with the result given here but now I see that I did not scroll till the end. It seems that the code in the answer return the 'non-normalized' binary representation (that page b.t.w. very explicitly provides the recipe for how to obtain the 32-bit IEEE 754 representation and this page for the 64-bit version).

I will leave the answer here anyway.

END EDIT

You can't. Emacs Lisp is a highly abstract, strongly typed dynamic language where everything is a reference. It determines the data type through the highest bits of pointers in C language. If you want to treat a floating point number as an integer, you have to modify some bits of the pointer. This can't be done in Emacs Lisp; you must modify it through a debugger like GDB.

But you can write a function to find out the precise representation of a floating point number. As per the elisp manual, Emacs Lisp follows IEEE-754.

You can't. Emacs Lisp is a highly abstract, strongly typed dynamic language where everything is a reference. It determines the data type through the highest bits of pointers in C language. If you want to treat a floating point number as an integer, you have to modify some bits of the pointer. This can't be done in Emacs Lisp; you must modify it through a debugger like GDB.

But you can write a function to find out the precise representation of a floating point number. As per the elisp manual, Emacs Lisp follows IEEE-754.

EDIT

I quickly checked the result with the result given here but now I see that I did not scroll till the end. It seems that the code in the answer return the 'non-normalized' binary representation (that page b.t.w. very explicitly provides the recipe for how to obtain the 32-bit IEEE 754 representation and this page for the 64-bit version).

I will leave the answer here anyway.

END EDIT

You can't. Emacs Lisp is a highly abstract, strongly typed dynamic language where everything is a reference. It determines the data type through the highest bits of pointers in C language. If you want to treat a floating point number as an integer, you have to modify some bits of the pointer. This can't be done in Emacs Lisp; you must modify it through a debugger like GDB.

But you can write a function to find out the precise representation of a floating point number. As per the elisp manual, Emacs Lisp follows IEEE-754.

Source Link
shynur
  • 5.9k
  • 1
  • 5
  • 28

You can't. Emacs Lisp is a highly abstract, strongly typed dynamic language where everything is a reference. It determines the data type through the highest bits of pointers in C language. If you want to treat a floating point number as an integer, you have to modify some bits of the pointer. This can't be done in Emacs Lisp; you must modify it through a debugger like GDB.

But you can write a function to find out the precise representation of a floating point number. As per the elisp manual, Emacs Lisp follows IEEE-754.