Literal syntax for integers

Джерело:
Common Lisp Tips

Дата публікації:
02/03/2013 16:30

Постійна адреса новини:
http://www.vsinovyny.com/8323840

Literal syntax for integers

 

02/03/2013 16:30 // Common Lisp Tips

There are several ways to write literal integers with different radixes in Common Lisp. #b… is for binary, #o… is for octal, #x… is for hexadecimal, and #r is for an arbitrary radix from 2 to 36. Section 2.4.8.10 has this example:

#2r11010101  ;Another way of writing 213 decimal  
#b11010101   ;Ditto                               
#b+11010101  ;Ditto                               
#o325        ;Ditto, in octal radix               
#xD5         ;Ditto, in hexadecimal radix         
#16r+D5      ;Ditto                               
#o-300       ;Decimal -192, written in base 8     
#3r-21010    ;Same thing in base 3                
#25R-7H      ;Same thing in base 25               
#xACCEDED    ;181202413, in hexadecimal radix

 

» Читати повністю

 

« Наступна новина з архіву
Formatting integers in different radixes
  Попередня новина з архіву
How do I convert an integer to a list of bits?
»

 

 
© 2026 www.vsinovyny.com