Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4085968
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:39:31+00:00 2026-05-20T18:39:31+00:00

I want to turn a large number, actually the present time in seconds counted

  • 0

I want to turn a large number, actually the present time in seconds counted from the unix epoch time, into a hexatridecimal string.

I hacked some code a long time ago, which (I think) worked on an earlier version of emacs, but it does not work any more on emacs 23 that I use now (It might be possible that I messed up the code).

The difficulty at the time I wrote it was that the number was large to be handled as one argument for certain functions, so I had to divide it, do something, and put them together. For example, if you give a large number to string-to-number, it gives back a float even though I want an integer.

Can anyone suggest a rewrite of it?

Following is the broken code that I wrote. It does not work, but may give you an idea of what I am trying to do. First, these are all subroutines that are used below:

(defun seconds-since-origin ()
    (string-to-number (concat
        (number-to-string (- (string-to-number
            (substring (format-time-string "%s") 0 5)
         ) 10000))
    (substring (format-time-string "%s") 5)
)))

(defun hexatridecimal (decimal)
(concat
    (let ((quotient (/ decimal 36)))    (if (> quotient 35)
        (hexatridecimal quotient)
        (hexatridecimal-digit quotient)
    ))
    (hexatridecimal-digit (% decimal 36))
))

(defun hexatridecimal-digit (number)
    (nth number (list
"0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f" "g" "h" "i" "j"
    "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"))
)

The following will be the main function that will be called:

(hexatridecimal (seconds-since-origin))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:39:32+00:00Added an answer on May 20, 2026 at 6:39 pm

    Using a 64-bit Emacs (which can handle integers like you’re using), make the following changes:

    (defun seconds-since-origin ()
      (string-to-number (format-time-string "%s")))
    
    (defun hexatridecimal (decimal)
      (let ((quotient (/ decimal 36))
            (remainder (% decimal 36)))
        (concat 
         (if (> quotient 0)
             (hexatridecimal quotient)
           "")
         (hexatridecimal-digit remainder))))
    

    Note: this does assume a 64-bit Emacs which has more bits for large integers than the 32-bit builds.

    If you want to work on a 32-bit Emacs, you can use calc‘s big-int capability to do the maths for you, and adjust the code appropriately.

    Edited to add:
    Here’s the version using calc‘s bignum capabilities:

    (require 'calc)
    (require 'calc-ext)
    (defun seconds-since-origin ()
      (math-read-number-simple (format-time-string "%s")))
    (defun hexatridecimal (decimal-bignum)
      (let* ((q-r (math-idivmod decimal-bignum 36))
         (quotient (car q-r))
         (remainder (cdr q-r)))
    (concat 
     (if (math-lessp 0 quotient)
         (hexatridecimal quotient)
       "")
     (hexatridecimal-digit remainder))))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of points that i want to turn into a closed
I have a list of objects which I want to turn into a set.
I created a console application, but I want to turn it into a windows
This array holds a list of items, and I want to turn it into
I have the following array, $myarray[0]['first_name'] $myarray[0]['last_name'] I want to turn it into: $myarray['first_name']
I want to send a large amount of cached json data from an import
I want to turn off dumping out the contents of the entire data model
I want to turn something like this CS 240, CS 246, ECE 222, ...
dev%40bionic%2Dcomms%2Eco%2Euk I want to turn the above back in to readable text. Can anyone
I made an MFC application, and now i want to turn off the window's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.