CN112287638A - Digital display method and device - Google Patents

Digital display method and device Download PDF

Info

Publication number
CN112287638A
CN112287638A CN202011172433.7A CN202011172433A CN112287638A CN 112287638 A CN112287638 A CN 112287638A CN 202011172433 A CN202011172433 A CN 202011172433A CN 112287638 A CN112287638 A CN 112287638A
Authority
CN
China
Prior art keywords
displayed
result
index
digit
output result
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011172433.7A
Other languages
Chinese (zh)
Other versions
CN112287638B (en
Inventor
吴凡
刘喜乐
魏增艺
邹永强
杨晖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Accumulus Technologies Tianjin Co Ltd
Original Assignee
Accumulus Technologies Tianjin Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Accumulus Technologies Tianjin Co Ltd filed Critical Accumulus Technologies Tianjin Co Ltd
Priority to CN202011172433.7A priority Critical patent/CN112287638B/en
Publication of CN112287638A publication Critical patent/CN112287638A/en
Application granted granted Critical
Publication of CN112287638B publication Critical patent/CN112287638B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/111Mathematical or scientific formatting; Subscripts; Superscripts

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Optimization (AREA)
  • Mathematical Physics (AREA)
  • Pure & Applied Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Mathematical Analysis (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • General Engineering & Computer Science (AREA)
  • Algebra (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The invention provides a digital display method and a digital display device, wherein the method comprises the following steps: receiving a request for displaying a user interface; obtaining an index a of 10 after a number X to be displayed uses a scientific counting method; if the index a is less than or equal to 3, taking the number X to be displayed as an output result; if the index a is larger than 3, determining a corresponding maximum counting unit when the number X to be displayed is displayed; if the corresponding maximum counting unit is ten thousand when the number X to be displayed is displayed, converting the number X to be displayed into an output result taking the ten thousand as the counting unit; if the corresponding maximum counting unit is billion or trillion when the number X to be displayed is displayed, converting the number X to be displayed into an output result taking billion or trillion as the counting unit; and displaying the output result on a user interface. The invention realizes the input of original digits, reserves the specified decimal digit, and outputs a digit with Chinese units, so that the data is not redundant.

Description

Digital display method and device
Technical Field
The invention relates to the field of data storage, in particular to a digital display method and a digital display device.
Background
The requirement of formatting numbers into units with Chinese is needed in programming, and some existing algorithms and tools in the industry at present are formatted according to thousands of characters according to western habits, have no units of 'ten thousand', 'hundred million', 'trillion', and only have 'million', 'billion', and the like, and users need to carry out reprocessing by themselves; in the data formatting process, because there is a lack of corresponding ready-made tool functions to convert the number of digital band units, for example, 2341200 is converted into 234.12 thousands, which also causes certain difficulty in data storage, causes data storage redundancy, and has hidden troubles in data synchronization and the like.
Disclosure of Invention
The invention provides a number display method and a number display device, which are used for solving the problems that when numbers are formatted, no tool for correspondingly converting the numbers into the format of a Chinese unit causes the use trouble of a user and the data storage redundancy.
In order to solve the above problems, the present invention is realized by:
in a first aspect, an embodiment of the present invention provides a digital display method, including:
receiving a request for displaying a user interface;
if the number needs to be displayed in the user interface, responding to the request, and acquiring a number X to be displayed;
obtaining an index a of 10 after the number X to be displayed uses a scientific counting method;
if the index a is less than or equal to 3, taking the number X to be displayed as an output result;
if the index a is larger than 3, determining a corresponding maximum counting unit when the number X to be displayed is displayed;
if the corresponding maximum counting unit is ten thousand when the number X to be displayed is displayed, converting the number X to be displayed into an output result taking ten thousand as the counting unit;
if the corresponding maximum counting unit of the number X to be displayed is billion or trillion when being displayed, converting the number X to be displayed into an output result taking billion or trillion as the counting unit;
displaying the output result on the user interface.
Optionally, displaying the output result on the user interface includes:
if the first digit after the decimal point is reserved for the output result is detected to be agreed in advance, reserving the first decimal decimalLength after the decimal point when the output result is displayed;
and if the number of bits after the decimal point is required to be reserved for the output result is detected to be unconfined, defaulting the second decimal decimalLength after the decimal point is reserved when the output result is displayed.
Optionally, obtaining an index a of the number X to be displayed after using a scientific counting method by 10 includes:
if the number X to be displayed is a positive number less than or equal to 1, directly outputting an initial value of an index, wherein the initial value of the index is defaulted to-1;
if the number X to be displayed is larger than 1, executing the following steps:
adding 1 to the initial value count of the index to obtain a first index, and simultaneously moving the decimal point of the number X to be displayed by one bit to the left to obtain a number after the decimal point is moved by one bit to the left;
judging whether the number of the decimal point shifted left by one bit is larger than 1;
if the number of the decimal point shifted to the left by one digit is larger than 1, adding 1 to the first exponent, shifting the decimal point of the number of the decimal point shifted to the left by one digit again to the left to obtain a new number of the decimal point shifted to the left by one digit, and returning to the step of judging whether the number of the decimal point shifted to the left by one digit is larger than 1;
and if the number of the decimal point after being shifted by one bit to the left is less than or equal to 1, outputting the current first exponent as the exponent a.
Optionally, determining the maximum count unit corresponding to the number X to be displayed when displaying includes:
carrying out rounding operation on the index a to obtain a rounding result c obtained by dividing the index a by 8;
if the rounding result c is less than 1, converting the number X to be displayed into an output result taking ten thousand as a counting unit;
and if the rounding result c is greater than or equal to 1, converting the number X to be displayed into an output result taking billions or trillions as counting units.
Optionally, converting the number X to be displayed into an output result taking "ten thousand" as a counting unit, includes:
performing modular operation on the index a to obtain a result b obtained by performing modular operation on the index a by 8;
judging whether the result b is greater than or equal to 5;
if the result b is more than or equal to 5, the result b is output as 4, and the number X to be displayed is reduced to 10-(b-decimalLength)And rounded off and then reduced to 10-decimalLengthObtaining a digit A after format conversion;
if the result b is less than 5, the number X to be displayed is reduced to 10-(b-decimalLength)And rounded off and then reduced to 10-decimalLengthObtaining a digit A after format conversion;
adding the unit of ten thousand to the digit A after the format conversion.
Optionally, the number X to be displayed is converted into an output result in units of "hundred million" or "trillion", including:
obtaining the digital X zoom out to be presented
Figure BDA0002747708640000031
And rounding the result to obtain an integer part d;
obtaining an index a' of 10 after the integer part d uses a scientific counting method;
if the index a' is less than or equal to 3, the number X to be displayed is reduced to the original number
Figure BDA0002747708640000032
After rounding off, the product is reduced to 10-decimalLengthObtaining a converted number B;
if the index a' is larger than 3, performing modular operation on the integer part d to obtain a result e obtained by performing modular operation on the integer part d by 8;
judging whether the result e is greater than or equal to 5;
if the result e is more than or equal to 5, the result b is output as 4, and the number X to be displayed is reduced to the original number
Figure BDA0002747708640000033
After rounding off, the product is reduced to 10-decimalLengthObtaining a digit C after format conversion;
if the result e is less than 5, the number X to be displayed is reduced to the original number
Figure BDA0002747708640000034
After rounding off, the product is reduced to 10-decimalLengthObtaining a digit C after format conversion;
adding a unit of ten thousand to the digit C after format conversion;
judging the relation between the rounding result c and a count value i, wherein the count value i is defaulted to 0;
if the rounding result C is less than or equal to the count value i, directly outputting the number C after the unit is added;
if the rounding result c is larger than the count value i, executing the following steps:
adding units of hundred million behind the number B or the number C after the adding unit of ten thousand;
adding 2 to the counting value to obtain a new counting value;
judging the relation between the rounding result c and the new count value i;
and if the rounding result C is larger than the new count value i, returning to the step of adding units of hundred million behind the number B or the number C after adding the units of ten thousand.
In a second aspect, an embodiment of the present invention provides a digital display apparatus, including:
the receiving module is used for receiving a request for displaying a user interface;
the first acquisition module is used for responding to the request and acquiring the number X to be displayed if the number needs to be displayed in the user interface;
the second acquisition module is used for acquiring the index a of 10 after the number X to be displayed uses a scientific counting method;
the first processing module is used for taking the number X to be displayed as an output result if the index a is less than or equal to 3;
the second processing module is used for determining the maximum counting unit corresponding to the number X to be displayed when the index a is larger than 3;
the third processing module is used for converting the number X to be displayed into an output result taking ten thousand as a counting unit if the corresponding maximum counting unit is ten thousand when the number X to be displayed is displayed;
the fourth processing module is used for converting the number X to be displayed into an output result taking the number hundred million or trillion as a counting unit if the corresponding maximum counting unit is hundred million or trillion when the number X to be displayed is displayed;
and the output module is used for displaying the output result on the user interface.
Optionally, the third obtaining module is configured to obtain a first decimal decimalLength after the decimal point that needs to be reserved after the conversion of the number X to be displayed;
and the fifth processing module is used for defaulting to reserve a second decimal if the first decimal decimalLength after the decimal point which needs to be reserved after the conversion of the number X to be displayed is not acquired.
In a third aspect, a server is provided, which comprises a processor, a memory and a program or instructions stored on the memory and executable on the processor, the program or instructions, when executed by the processor, implementing the steps of the digital exhibition method according to the first aspect.
In a fourth aspect, a readable storage medium is provided, on which a program or instructions are stored, which program or instructions, when executed by a processor, implement the steps of the digital exhibition method according to the first aspect.
The embodiment of the invention provides a flexible digital formatting function, which outputs a number formatted into a Chinese unit by inputting an original number and reserving appointed decimal digits, and simultaneously, a database only needs to store the original number and calls the embodiment to format at a required place, thereby solving the problem of data redundancy caused by additionally storing the formatted number.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 is a flowchart of a digital display method according to an embodiment of the present invention;
fig. 2 is a flowchart of obtaining an index a in a digital display method according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating a method for obtaining a maximum count unit according to an embodiment of the present invention;
fig. 4 is a flowchart of adding a unit "ten thousand" in the digital display method according to the embodiment of the present invention;
FIG. 5 is a flow chart of adding units "hundred million" and "trillion" in a digital display method according to an embodiment of the present invention;
FIG. 6 is a block diagram of a digital display apparatus according to an embodiment of the present invention;
fig. 7 is a diagram of a server architecture according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the drawings of the embodiments of the present invention. It is to be understood that the embodiments described are only a few embodiments of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the described embodiments of the invention, are within the scope of the invention.
Unless defined otherwise, technical or scientific terms used herein shall have the ordinary meaning as understood by one of ordinary skill in the art to which this invention belongs. The use of "first," "second," and similar terms in the present application do not denote any order, quantity, or importance, but rather the terms are used to distinguish one element from another. The terms "connected" or "coupled" and the like are not restricted to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "upper", "lower", "left", "right", and the like are used merely to indicate relative positional relationships, and when the absolute position of the object being described is changed, the relative positional relationships are changed accordingly.
Referring to fig. 1, an embodiment of the present invention provides a digital display method, including:
step 11: receiving a request for displaying a user interface;
step 12: if the number needs to be displayed in the user interface, responding to the request, and acquiring a number X to be displayed;
step 13: obtaining an index a of 10 after the number X to be displayed uses a scientific counting method;
step 14: if the index a is less than or equal to 3, taking the number X to be displayed as an output result;
step 15: if the index a is larger than 3, determining a corresponding maximum counting unit when the number X to be displayed is displayed;
step 16: if the corresponding maximum counting unit is ten thousand when the number X to be displayed is displayed, converting the number X to be displayed into an output result taking ten thousand as the counting unit;
and step 17: if the corresponding maximum counting unit of the number X to be displayed is billion or trillion when being displayed, converting the number X to be displayed into an output result taking billion or trillion as the counting unit;
step 18: displaying the output result on the user interface.
In the embodiment of the invention, the back end does not need to process data, only the original data is saved, and the method in the embodiment is called to format when the number needs to be displayed, so that the problem of data redundancy caused by additionally storing the formatted number is solved.
In this embodiment of the present invention, optionally, displaying the output result on the user interface includes:
if the first digit after the decimal point is reserved for the output result is detected to be agreed in advance, reserving the first decimal decimalLength after the decimal point when the output result is displayed;
and if the number of bits after the decimal point is required to be reserved for the output result is detected to be unconfined, defaulting the second decimal decimalLength after the decimal point is reserved when the output result is displayed.
In the embodiment of the present invention, the digit after the decimal point is reserved as the digit reserved by the digit before the unit after adding the unit, for example: 1234560.789123, if the number of digits after the decimal point that the input/output result needs to be preserved is three, the result is formatted to be 123.456 ten thousands; if it is detected that the number of bits after the decimal point required for the output result is not predetermined, the default reserved number of bits is usually set to two decimal places, for example: 456780000000000.123 if there is no decimal place to be reserved for the input/output result, it is formatted to 456.78 trillion.
Referring to fig. 2, in the embodiment of the present invention, optionally, in step 13, obtaining an index a of the number X to be displayed after using the scientific counting method 10 includes:
step 21: if the number X to be displayed is a positive number less than or equal to 1, directly outputting an initial value of the exponent, wherein the initial value of the exponent is defaulted to-1;
step 22: if the number X to be displayed is larger than 1, executing the following steps:
step 221: adding 1 to the initial value count of the index to obtain a first index, and simultaneously moving the decimal point of the number X to be displayed by one bit to the left to obtain a digit after the decimal point is moved by one bit to the left;
step 222: judging whether the number of the decimal point shifted left by one bit is larger than 1;
step 223: if the number of the decimal point shifted to the left by one digit is larger than 1, adding 1 to the first exponent, shifting the decimal point of the number of the decimal point shifted to the left by one digit again to the left to obtain a new number of the decimal point shifted to the left by one digit, and returning to the step of judging whether the number of the decimal point shifted to the left by one digit is larger than 1;
step 224: and if the number of the decimal point after being shifted by one bit to the left is less than or equal to 1, taking the current first index as the index a and outputting the index a.
In the embodiment of the present invention, the parameter obtained by the step is an index a of the number X to be displayed after the number X is subjected to a scientific counting method by 10, for example: the number 123000000 is recorded as 1.23 × 10 using scientific counting method8The index a is 8.
Referring to fig. 3, in the embodiment of the present invention, optionally, in step 15, determining a maximum count unit corresponding to the number X to be displayed when displaying includes:
step 31: carrying out rounding operation on the index a to obtain a rounding result c obtained by dividing the index a by 8;
step 32: judging whether the rounding result c is less than 1;
step 32: if the rounding result c is less than 1, converting the number X to be displayed into an output result taking ten thousand as a counting unit;
step 33: and if the rounding result c is greater than or equal to 1, converting the number X to be displayed into an output result taking billions or trillions as counting units.
In the embodiment of the invention, the number X to be displayed is judged to be in the unit of ten thousand or more by rounding 8 by the index a.
Referring to fig. 4, in the embodiment of the present invention, optionally, in step 16, converting the number X to be displayed into an output result taking "ten thousand" as a counting unit, includes:
step 41: performing modular operation on the index a to obtain a result b obtained by performing modular operation on the index a by 8;
step 42: judging whether the result b is greater than or equal to 5;
step 43: if the result b is greater than or equal to 5, the result b is output as 4, and the number X to be displayed is reduced to the original M-10-(b-decimalLength)After rounding off, the N is reduced to 10-decimalLengthObtaining a digit A after format conversion;
step 44: if the result b is less than 5, the number X to be displayed is reduced to 10-(b-decimalLength)After rounding off, the N is reduced to 10-decimalLengthObtaining a digit A after format conversion;
step 45: adding the unit of ten thousand to the digit A after the format conversion.
In the embodiment of the invention, the modulus operation is carried out on the index a, and the result b obtained after the index a is subjected to the modulus operation by 8 is used for excluding the part of an adding unit of hundred million; whether b is larger than 5 is judged to set b to be 4, so that the conditions of 'one hundred thousand', 'one million' and 'ten million' are processed according to 'ten thousand'.
Referring to fig. 5, in an embodiment of the present invention, optionally, in step 17, the converting the number X to be displayed into an output result with "hundred million" or "trillion" as a counting unit includes:
step 51: obtaining the digital X zoom out to be presented
Figure BDA0002747708640000082
Performing four-round and five-round on the result to obtain an integer part d;
step 52: obtaining an index a' of 10 after the integer part d uses a scientific counting method;
step 53: if the index a' is less than or equal to 3, the number X to be displayed is reduced to the original number
Figure BDA0002747708640000083
After rounding off, the N is reduced to 10-decimalLengthObtaining a converted number B;
step 54: if the exponent a' is larger than 3, performing modular operation on the integer part d to obtain a result e obtained by performing modular operation on the integer part d by 8;
step 55: judging whether the result e is greater than or equal to 5;
step 56: if the result e is more than or equal to 5, the result b is output as 4, and the number X to be displayed is reduced to the original number
Figure BDA0002747708640000091
After rounding off, the N is reduced to 10-decimalLengthObtaining a digit C after format conversion;
step 57, if the result e is less than 5, the number X to be displayed is reduced to the original number
Figure BDA0002747708640000092
After rounding off, the N is reduced to 10-decimalLengthObtaining a digit C after format conversion;
step 58: adding a unit of ten thousand to the digit C after format conversion;
step 59: judging the relation between the rounding result c and a count value i, wherein the count value i is defaulted to 0;
if the rounding result C is less than or equal to the count value i, directly outputting the number C after the unit is added;
if the rounding result c is larger than the count value i, executing the following steps:
step 591: adding units of hundred million behind the number B or the number C after the adding unit of ten thousand;
step 592: adding 2 to the counting value to obtain a new counting value;
returning and judging the relation between the rounding result c and the new count value i;
step 593: and if the rounding result C is larger than the new count value i, returning to the step of adding units of hundred million behind the number B or the number C after adding the units of ten thousand.
In the embodiment of the invention, in the processing of the units of billions and trillions, the units of trillions are processed firstly, then the units of trillions are added, and the units of trillions are obtained by rounding 8.
The embodiment of the invention provides a flexible digital formatting function, which outputs a number formatted into a Chinese unit by inputting an original number and reserving appointed decimal digits, and simultaneously, a database only needs to store the original number and calls the embodiment to format at a required place, thereby solving the problem of data redundancy caused by additionally storing the formatted number.
Referring to fig. 6, an embodiment of the present invention provides a digital display apparatus, including:
a receiving module 61, configured to receive a request for displaying a user interface;
a first obtaining module 62, configured to, if a number needs to be displayed in the user interface, obtain, in response to the request, a number X to be displayed;
a second obtaining module 63, configured to obtain an index a of the to-be-displayed number X after the number X uses a scientific counting method by 10;
a first processing module 64, configured to take the number X to be displayed as an output result if the exponent a is less than or equal to 3;
a second processing module 65, configured to determine, if the index a is greater than 3, a maximum count unit corresponding to the number X to be displayed when displaying;
a third processing module 66, configured to, if the maximum counting unit corresponding to the number X to be displayed is "ten thousand", convert the number X to be displayed into an output result with "ten thousand" as a counting unit;
a fourth processing module 67, configured to convert the number X to be displayed into an output result taking the number of hundred million or trillion as a counting unit if the maximum counting unit corresponding to the number X to be displayed is hundred million or trillion when the number X to be displayed is displayed;
an output module 68 configured to display the output result on the user interface.
In the embodiment of the invention, the back end does not need to process data, only the original data is saved, and the method in the embodiment is called to format when the number needs to be displayed, so that the problem of data redundancy caused by additionally storing the formatted number is solved.
In the embodiment of the present invention, optionally, the third obtaining module is configured to obtain a first decimal decimalLength after the decimal point that needs to be reserved after the conversion of the digital X to be displayed;
and the fifth processing module is used for defaulting to reserve a second decimal if the first decimal decimalLength after the decimal point which needs to be reserved after the conversion of the number X to be displayed is not acquired.
In the embodiment of the present invention, the digit after the decimal point is reserved as the digit reserved by the digit before the unit after adding the unit, for example: 1234560.789123, if the number of digits after the decimal point that the input/output result needs to be preserved is three, the result is formatted to be 123.456 ten thousands; if it is detected that the number of bits after the decimal point required for the output result is not predetermined, the default reserved number of bits is usually set to two decimal places, for example: 456780000000000.123 if there is no decimal place to be reserved for the input/output result, it is formatted to 456.78 trillion.
The embodiment of the invention provides a flexible digital formatting function, which outputs a number formatted into a Chinese unit by inputting an original number and reserving appointed decimal digits, and simultaneously, a database only needs to store the original number and calls the embodiment to format at a required place, thereby solving the problem of data redundancy caused by additionally storing the formatted number.
Referring to fig. 7, an embodiment of the present invention further provides a server 70, which includes a processor 71, a memory 72, and a computer program stored in the memory 72 and capable of running on the processor 71, where the computer program, when executed by the processor 71, implements the processes of the digital display method embodiment applied to the server, and can achieve the same technical effects, and therefore, in order to avoid repetition, the descriptions are omitted here.
The embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements each process of the above digital display method embodiment, and can achieve the same technical effect, and in order to avoid repetition, the details are not repeated here. The computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
Through the above description of the embodiments, those skilled in the art will clearly understand that the above embodiment method can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solution of the present invention may be substantially or partially embodied in the form of a software product stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk), and including instructions for enabling a terminal (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The foregoing is a preferred embodiment of the present invention, and it should be noted that it is obvious to those skilled in the art that various modifications and improvements can be made without departing from the principle of the present invention, and these modifications and improvements should be construed as the protection scope of the present invention.

Claims (10)

1. A digital display method, comprising:
receiving a request for displaying a user interface;
if the number needs to be displayed in the user interface, responding to the request, and acquiring a number X to be displayed;
obtaining an index a of 10 after the number X to be displayed uses a scientific counting method;
if the index a is less than or equal to 3, taking the number X to be displayed as an output result;
if the index a is larger than 3, determining a corresponding maximum counting unit when the number X to be displayed is displayed;
if the corresponding maximum counting unit is ten thousand when the number X to be displayed is displayed, converting the number X to be displayed into an output result taking ten thousand as the counting unit;
if the corresponding maximum counting unit of the number X to be displayed is billion or trillion when being displayed, converting the number X to be displayed into an output result taking billion or trillion as the counting unit;
displaying the output result on the user interface.
2. The digital exhibition method of claim 1, wherein displaying the output result on the user interface comprises:
if the first digit after the decimal point is reserved for the output result is detected to be agreed in advance, reserving the first decimal decimalLength after the decimal point when the output result is displayed;
and if the digit number of the output result after the decimal point is required to be reserved is detected not to be agreed in advance, when the output result is displayed, the decimal decimalLength of the second digit after the decimal point is reserved is set as a default.
3. The digital display method of claim 1, wherein obtaining an index a of 10 after the scientific counting method used by the number X to be displayed comprises:
if the number X to be displayed is a positive number less than or equal to 1, directly outputting an initial value of an index, wherein the initial value of the index is defaulted to-1;
if the number X to be displayed is larger than 1, executing the following steps:
adding 1 to the initial value count of the index to obtain a first index, and simultaneously moving the decimal point of the number X to be displayed by one bit to the left to obtain a number after the decimal point is moved by one bit to the left;
judging whether the number of the decimal point shifted left by one bit is larger than 1;
if the number of the decimal point shifted to the left by one digit is larger than 1, adding 1 to the first exponent, shifting the decimal point of the number of the decimal point shifted to the left by one digit again to the left to obtain a new number of the decimal point shifted to the left by one digit, and returning to the step of judging whether the number of the decimal point shifted to the left by one digit is larger than 1;
and if the number of the decimal point after being shifted by one bit to the left is less than or equal to 1, outputting the current first exponent as the exponent a.
4. The digital display method of claim 2, wherein determining the maximum count unit corresponding to the displayed number X comprises:
carrying out rounding operation on the index a to obtain a rounding result c obtained by dividing the index a by 8;
if the rounding result c is less than 1, converting the number X to be displayed into an output result taking ten thousand as a counting unit;
and if the rounding result c is greater than or equal to 1, converting the number X to be displayed into an output result taking billions or trillions as counting units.
5. The digital exhibition method of claim 2, wherein converting the number X to be exhibited into an output result in units of "ten thousand" counts comprises:
performing modular operation on the index a to obtain a result b obtained by performing modular operation on the index a by 8;
judging whether the result b is greater than or equal to 5;
if the result b is more than or equal to 5, the result b is output as 4, and the number X to be displayed is reduced to 10-(b-decimalLength)And rounded off and then reduced to 10-decimalLengthObtaining a digit A after format conversion;
if the result b is less than 5, the number X to be displayed is reduced to 10-(b-decimalLength)And rounded off and then reduced to 10-decimalLengthObtaining a digit A after format conversion;
adding the unit of ten thousand to the digit A after the format conversion.
6. The digital exhibition method according to claim 4, wherein converting the number X to be exhibited into output results in units of counts of "hundred million" or "trillion" includes:
obtaining the digital X zoom out to be presented
Figure FDA0002747708630000021
And rounding the result to obtain an integer part d;
obtaining an index a' of 10 after the integer part d uses a scientific counting method;
if the index a' is less than or equal to 3, the number X to be displayed is reduced to the original number
Figure FDA0002747708630000022
After rounding off, the product is reduced to 10-decimalLengthObtaining a converted number B;
if the index a' is larger than 3, performing modular operation on the integer part d to obtain a result e obtained by performing modular operation on the integer part d by 8;
judging whether the result e is greater than or equal to 5;
if the result e is more than or equal to 5, the result b is output as 4, and the number X to be displayed is reduced to the original number
Figure FDA0002747708630000031
After rounding off, the product is reduced to 10-decimalLengthObtaining a digit C after format conversion;
if the result e is less than 5, the number X to be displayed is reduced to the original number
Figure FDA0002747708630000032
After rounding off, the product is reduced to 10-decimalLengthObtaining a digit C after format conversion;
adding a unit of ten thousand to the digit C after format conversion;
judging the relation between the rounding result c and a count value i, wherein the count value i is defaulted to 0;
if the rounding result C is less than or equal to the counting value i, directly outputting the number C after the unit is added;
if the rounding result c is larger than the count value i, executing the following steps:
adding units of hundred million behind the number B or the number C after the adding unit of ten thousand;
adding 2 to the counting value to obtain a new counting value;
judging the relation between the rounding result c and the new count value i;
and if the rounding result C is larger than the new count value i, returning to the step of adding units of hundred million behind the number B or the number C after adding the units of ten thousand.
7. A digital display device, comprising:
the receiving module is used for receiving a request for displaying a user interface;
the first acquisition module is used for responding to the request and acquiring the number X to be displayed if the number needs to be displayed in the user interface;
the second acquisition module is used for acquiring an index a of 10 after the number X to be displayed uses a scientific counting method;
the first processing module is used for taking the number X to be displayed as an output result if the index a is less than or equal to 3;
the second processing module is used for determining the corresponding maximum counting unit when the number X to be displayed is displayed if the index a is larger than 3;
the third processing module is used for converting the number X to be displayed into an output result taking ten thousand as a counting unit if the corresponding maximum counting unit is ten thousand when the number X to be displayed is displayed;
the fourth processing module is used for converting the number X to be displayed into an output result taking the number hundred million or trillion as a counting unit if the corresponding maximum counting unit is hundred million or trillion when the number X to be displayed is displayed;
and the output module is used for displaying the output result on the user interface.
8. The digital display apparatus of claim 7, further comprising:
the third acquisition module is used for acquiring a first decimal decimalLength after the decimal point which needs to be reserved after the conversion of the number X to be displayed;
and the fifth processing module is used for defaulting to reserve a second decimal if the first decimal decimalLength after the decimal point which needs to be reserved after the conversion of the number X to be displayed is not acquired.
9. A server, comprising a processor, a memory, and a program or instructions stored on the memory and executable on the processor, the program or instructions, when executed by the processor, implementing the steps of the digital exhibition method of claims 1-6.
10. A readable storage medium, on which a program or instructions are stored, which, when executed by a processor, carry out the steps of the digital exhibition method according to claims 1-6.
CN202011172433.7A 2020-10-28 2020-10-28 Digital display method and device Active CN112287638B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011172433.7A CN112287638B (en) 2020-10-28 2020-10-28 Digital display method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011172433.7A CN112287638B (en) 2020-10-28 2020-10-28 Digital display method and device

Publications (2)

Publication Number Publication Date
CN112287638A true CN112287638A (en) 2021-01-29
CN112287638B CN112287638B (en) 2022-12-09

Family

ID=74373023

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011172433.7A Active CN112287638B (en) 2020-10-28 2020-10-28 Digital display method and device

Country Status (1)

Country Link
CN (1) CN112287638B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113420538A (en) * 2021-08-23 2021-09-21 深圳市明源云科技有限公司 Numerical value format intelligent display method, equipment terminal and computer readable storage medium
CN114115740A (en) * 2021-11-26 2022-03-01 百度在线网络技术(北京)有限公司 Data storage method and device, data acquisition method and device, and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180278264A1 (en) * 2017-03-24 2018-09-27 Imagination Technologies Limited Floating Point to Fixed Point Conversion Using Exponent Offset
CN109299233A (en) * 2018-09-19 2019-02-01 平安科技(深圳)有限公司 Text data processing method, device, computer equipment and storage medium
CN111414728A (en) * 2020-03-05 2020-07-14 金蝶蝶金云计算有限公司 Numerical data display method and device, computer equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180278264A1 (en) * 2017-03-24 2018-09-27 Imagination Technologies Limited Floating Point to Fixed Point Conversion Using Exponent Offset
CN109299233A (en) * 2018-09-19 2019-02-01 平安科技(深圳)有限公司 Text data processing method, device, computer equipment and storage medium
CN111414728A (en) * 2020-03-05 2020-07-14 金蝶蝶金云计算有限公司 Numerical data display method and device, computer equipment and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
ADMIN: "js将数值转化为万、亿、万亿并保留两位小数", 《HTTPS://WWW.DDPOOL.CN/ARTICLE/7678.HTML,20190019》 *
EVEREST: "C#2.0纯数学方法递归实现货币数字转换中文", 《HTTPS://BLOG.CSDN.NET/EVEREST/ARTICLE/DETAILS/1672631》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113420538A (en) * 2021-08-23 2021-09-21 深圳市明源云科技有限公司 Numerical value format intelligent display method, equipment terminal and computer readable storage medium
CN113420538B (en) * 2021-08-23 2021-12-14 深圳市明源云科技有限公司 Numerical value format intelligent display method, equipment terminal and computer readable storage medium
CN114115740A (en) * 2021-11-26 2022-03-01 百度在线网络技术(北京)有限公司 Data storage method and device, data acquisition method and device, and electronic equipment
CN114115740B (en) * 2021-11-26 2024-06-07 百度在线网络技术(北京)有限公司 Data storage method and device, data acquisition method and device and electronic equipment

Also Published As

Publication number Publication date
CN112287638B (en) 2022-12-09

Similar Documents

Publication Publication Date Title
CN108388598B (en) Electronic device, data storage method, and storage medium
CN112287638B (en) Digital display method and device
CN104579360B (en) A kind of method and apparatus of data processing
CN107315729B (en) Data processing method, medium, device and computing equipment for chart
CN111159492A (en) Track point retrieval method and device, storage medium and terminal
CN112506880A (en) Data processing method and related equipment
US20120242706A1 (en) Mobile terminal and method for adjusting menu bar softkey display dynamically
CN110808738A (en) Data compression method, device, equipment and computer readable storage medium
CN110737473A (en) Data processing method and device, terminal and storage medium
CN113742332A (en) Data storage method, device, equipment and storage medium
CN107301017B (en) Data storage method and device
CN106156169B (en) Discrete data processing method and device
CN113157695B (en) Data processing method and device, readable medium and electronic equipment
CN105991400B (en) Group searching method and device
CN108182202B (en) Content update notification method, content update notification device, electronic equipment and storage medium
CN114065123A (en) Sparse matrix calculation method and acceleration device
CN107562562B (en) Method and system for setting extra information describing fault event
CN111324787A (en) Block chain data display method and device in block chain browser
CN110662185B (en) Sending method and device of chart short message and terminal equipment
CN111222352A (en) Form input method and device, equipment and storage medium thereof
CN115328892B (en) Business form data structure processing method, system, electronic device and medium
CN108984556B (en) Method, apparatus and computer-readable storage medium for data processing
CN113961558B (en) Front-end data storage method, device and storage medium
CN108132946B (en) Serialized data display method and device
CN115098500A (en) Data processing method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant