Skip to main content

Questions tagged [numbers]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
4 answers
247 views

How do you convert a vector of float numbers to bytes?

I need to convert a vector of float numbers to bytes. I can't seem to find a way to do that in emacs-lisp. Is it possible? For example how do I convert this vector [3.14] to bytes? [Update] See this ...
John Kitchin's user avatar
  • 11.9k
7 votes
7 answers
2k views

elisp: Why does + without parameters return 0?

In elisp + function without parameters gives 0, (+) ==> 0. * function without parameters give 1: (*) ==> 1. Only (/) gives error: wrong number of arguments. But in Python entering + without ...
zeynel's user avatar
  • 371
1 vote
1 answer
72 views

How to add numbers to all lines matching a certain regex?

I have a Markdown file like this: # Title ## My Theme Pellentesque dapibus suscipit ligula. ### Mine is yours Donec posuere augue in quam. ## Your Theme * Suspendisse potenti. * Aenean in sem ac ...
halloleo's user avatar
  • 1,355
0 votes
1 answer
53 views

How can I read a number as user input?

I would like a user to input a number using the minibuffer. What function should I call and how should it be used?
Dilna's user avatar
  • 1
0 votes
1 answer
102 views

Using `string-to-number` causes rounding/precision issue for specific floating point values

I am trying to convert an arbitrary string (whereby the decimal point is explicitly manipulated controlled) to a number (i.e. floating point) using string-to-number and I am running into either a ...
David's user avatar
  • 138
0 votes
1 answer
122 views

JSON parsing fails: json-parse-error "too big integer"

I'm trying to parse a JSON file which contains large numbers: { "uuid": "c73b470a-5efb-4d53-9ac6-c5f6487f227b", "description": "grains on square 64&...
fap's user avatar
  • 161
0 votes
2 answers
50 views

How to prevent digit loss in orgmode spreadsheets with elisp?

That's probably a low hanging fruit. Assume an orgmode spreadsheet with one side for input - a number - and the other side for output. The other side is specified with simple elisp code, taking the ...
starquake's user avatar
3 votes
3 answers
652 views

How can I check whether a string represents a number in Elisp?

I want to check whether the string variable s is a number (integer or float) formatted as a string. I thought it could be done using string-to-number like this (defun string-number-base-p (s) (...
orgtre's user avatar
  • 1,100
0 votes
2 answers
76 views

Interactive selection with hex codes

I want a function that can take a utf hexcode from the user, and use it to change the glasses-separator in glasses-mode. When I use completing-read using a list of hexcodes things for well and the ...
Dilna's user avatar
  • 1
1 vote
2 answers
167 views

Why can't I do this arithmetic operation on eshell? Error: "Symbol’s function definition is void: \,"

I am trying to run a simple addition operation in eshell. Trying with an illustrative minimal example: ~/$ (+ 1 -4) eshell returns: -3 Since the above operation worked out, I tried the real ...
Pedro Delfino's user avatar
0 votes
1 answer
11 views

Resetting value when modulus computes to 0

Am doing the following computation where dmax is 8, whilst dcur start at 1 and increases bf increments of 1. I would like that when (mod dcur dmax) is 0, I use the value 8 rather than the value 0. (...
Dilna's user avatar
  • 1
1 vote
2 answers
58 views

Next greater or lesser number than ARG in a list of integers

In this example, there is a list of integers '(2527 1771 2107 2317). The variable arg is an integer, which may or may not be one of the integers in the list. Q: How can an Emacs user ...
lawlist's user avatar
  • 19.2k
0 votes
1 answer
20 views

Expanding Abbrev Mode Alphabet

Is it possible to write some elisp code so that we can use numbers for Abbrev Mode abbreviations? E.g., m2 -> me too h4 -> hope for gr8 -> greate
xpt's user avatar
  • 477
0 votes
1 answer
40 views

Alternative to `read-number' that does not truncate floating point zeros

The function read-number truncates floating point zeros; e.g., (read-number "PROMPT: ") RET 100.00 => 100.0 I am seeking a similar alternative to read-number that will not truncate; e.g.,...
lawlist's user avatar
  • 19.2k
2 votes
1 answer
328 views

Does anyone know of a quick method to get hexadecimal line numbers in emacs?

Does anyone know of a quick method to get hexadecimal line numbers in emacs? I am using linum for line numbers. I suppose I could hack it, but just thought to ask first.
Roadowl's user avatar
  • 131
6 votes
1 answer
180 views

minor mode to display long integers?

I have to deal with long integers frequently, typically 9+ digits, and all of the digits matter (so scientific notation doesn't help me. Is there a minor mode that helps make it easier to visually ...
petermao's user avatar
0 votes
1 answer
111 views

How to replace a letter with its numerical alphabetic position?

I have this code: \author[p]{...} \author[bc]{...} \author[p]{...} \author[l,o]{...} \author[t,q]{...} \author[at]{...} \author[z]{...} \author[ak]{...} \author[az]{...} \author[ah,bq]{...} ... I ...
Onner Irotsab's user avatar
0 votes
2 answers
101 views

How to replace first 100 digits with letters?

I want to replace the first 104 digits as it follows: 1 --> a ... 26 --> z 27 --> aa ... 52 --> az 53 --> ba ... 104 --> bz I have tried as it follows: (...
Onner Irotsab's user avatar
1 vote
2 answers
384 views

How to subtract 1 from the nth element of a list of numbers?

How do I subtract 1 from the second element of the list (3 6)? (setq x '(3 6)) (- (nth 1 x) 1) The above quote does the math but does not return a modified list.
Sati's user avatar
  • 815
2 votes
2 answers
340 views

Representing leading zeroes in a list

I would like to have this table #+NAME: addition-table | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | |---+----+----+----+----+----+----+----+----+----+----| | 0 | 00 | 01 | 02 | 03 | 04 | ...
147pm's user avatar
  • 2,979
2 votes
2 answers
298 views

Treat all numbers as floats

Is there a way to get elisp to automatically treat all numeric variables as floating points without having to repeatedly use the float function? For example to a division function that outputs the "...
Quinn Culver's user avatar
1 vote
3 answers
169 views

How to delete numerals of a certain size from text

I'm pretty new to emacs, so I'm still learning all the functions. I'm trying to remove certain metadata from each line of several large .txt files (Bible translations) and was wondering if if there ...
augustinus's user avatar
2 votes
1 answer
592 views

How insert random number?

Suppose I has text: test hello The cursor is after word test. I need to insert random number? Also I need to set range of random (e.g. from 0 to 1000) The result maybe like this: test100 hello
a_subscriber's user avatar
  • 4,174
2 votes
1 answer
109 views

How to replace a digit by a letter?

I want to replace some digits by letters such that 1 ---> a 2 ---> b ... In emacs I have tried the following replacement: M-x query-replace-regexp RET \([0-9]+\) RET \,(string (+ ?a \#1)) RET ...
Onner Irotsab's user avatar
0 votes
4 answers
561 views

Hоw add numbers in differents lines?

Numbers in many lines: add numbers 4900 5171 5700 4033 8583 4208 2299 2199 1699 1949 1799 2199 1899 2099 2699 2499 1549 1749 1749 2049 2149 2299 2180 2349 2499 I want to adding all this numbers. ...
a_subscriber's user avatar
  • 4,174
2 votes
1 answer
820 views

How to use fixed point decimals in emacs lisp?

How to use large decimal numbers with fixed precision, like money amount, in emacs lisp? For example, I'm writing a function that takes amount of money as a parameter. When I pass large float like ...
Max Skyfire's user avatar
0 votes
1 answer
25 views

Adjust end index in selected region

Following the advice given here, I wrote the following code to enclose the text selection in phpbb italics tags : (defun wrap-in-phpbb-italics-tag (b e) "does what its name says." (interactive "...
Ewan Delanoy's user avatar
2 votes
1 answer
138 views

How should one interpret the printed representation of integers in Emacs Lisp?

I'm getting to grips with Emacs Lisp in GNU Emacs 25.3.2. While trying to understand the printed representation of integers I got confused by the following echo area output produced by C-x C-e: 10 -&...
Andrew L's user avatar
2 votes
2 answers
99 views

floating-point addition

Why am I getting these results? (+ 5.2 42.4 -1) 46.6 (+ 5.2 42.45 -1) 46.650000000000006 Couldn't the 2nd operation just output 46.65? Where does the 0000000000006 come from?
Quora Feans's user avatar
2 votes
2 answers
141 views

How can I use a char as a counter?

I have this LaTeX code: \begin{enumerate}[a] \affiliation{...} \affiliation{...} \affiliation{...} ... \affiliation{...} \end{enumerate} and, using a script written in Emacs Lisp, I want to ...
Onner Irotsab's user avatar
2 votes
1 answer
124 views

Why does (format "%x" some-large-number) produces incorrect results?

I wanted the hexadecimal string for a large integer such as below: (format "%x" 2738188573457603759) This returns 2600000000f95c00 which is incorrect, it should be 2600000000f95caf. The value of ...
David Sitsky's user avatar
7 votes
2 answers
2k views

Quickly Evaluate Infix Math Expression?

Is there a way to highlight and quickly evaluate a simple math expression without using elisp notation? For example, we can already evaluate the elisp expression (+ 1 1) in the following text snippet ...
George's user avatar
  • 919
1 vote
1 answer
245 views

elisp replace float number with half value

I need to replace below string: (24.0000,28.0000) .. controls (27.3100,28.0000) and (29.9800,25.3100) .. (29.9800,22.0000) to: (12,14) .. controls (13.655,14) and (14.99,12.655) .. (14.99,11) The ...
lucky1928's user avatar
  • 1,678
1 vote
1 answer
1k views

How to change the color of numbers for a theme?

Is there a way to set the color of numbers differently to that of regular text? for example, numbers such as: 1, 2F, 2.0f, 0x1234. Can this be changed by a theme author? If not, how can this be ...
ideasman42's user avatar
  • 8,916
2 votes
0 answers
631 views

In Emacs Lisp, how to convert roman numerals to an integer?

In Emacs Lisp, how to write an Emacs Lisp function to convert a natural number from roman numerals representation to the equivalent Emacs Lisp integer value? The Emacs Lisp function should be callable ...
Low Powah's user avatar
  • 317
5 votes
3 answers
569 views

How to increase the number of displayed digit decimals in Emacs calculator

Currently Emacs calculator (calculator not calc) only shows, up to three digit decimal values. For example calculating 22/7 gives 3.143. Is it possible to increase the number of displayed digit ...
Name's user avatar
  • 7,925