CN111078188A - Floating point data processing method and device in JavaScript operation and electronic equipment - Google Patents

Floating point data processing method and device in JavaScript operation and electronic equipment Download PDF

Info

Publication number
CN111078188A
CN111078188A CN201911297808.XA CN201911297808A CN111078188A CN 111078188 A CN111078188 A CN 111078188A CN 201911297808 A CN201911297808 A CN 201911297808A CN 111078188 A CN111078188 A CN 111078188A
Authority
CN
China
Prior art keywords
character string
integer
string data
data
floating point
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.)
Pending
Application number
CN201911297808.XA
Other languages
Chinese (zh)
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.)
Guangdong 3vjia Information Technology Co Ltd
Original Assignee
Guangdong 3vjia Information Technology 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 Guangdong 3vjia Information Technology Co Ltd filed Critical Guangdong 3vjia Information Technology Co Ltd
Priority to CN201911297808.XA priority Critical patent/CN111078188A/en
Publication of CN111078188A publication Critical patent/CN111078188A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
    • G06F7/483Computations with numbers represented by a non-linear combination of denominational numbers, e.g. rational numbers, logarithmic number system or floating-point numbers

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Nonlinear Science (AREA)
  • General Engineering & Computer Science (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The invention provides a floating point data processing method and device in JavaScript operation and electronic equipment, and relates to the technical field of computers, wherein the floating point data to be operated are obtained and converted into corresponding character string data; using decimal points of the character string data as mark bits to obtain decimal digits of the character string data; and converting the character string data into an integer to be operated corresponding to the floating point data to be operated based on the decimal number of the character string data, and operating based on the integer to be operated. The method effectively improves the calculation accuracy of the floating point data.

Description

Floating point data processing method and device in JavaScript operation and electronic equipment
Technical Field
The invention relates to the technical field of computers, in particular to a floating point data processing method and device in JavaScript operation and electronic equipment.
Background
In the application of browser web pages, it is necessary to perform addition, subtraction, multiplication and division on some floating point data, for example, when the floating point data is subjected to addition, subtraction, multiplication, division (+ -) calculation by using JavaScript program language syntax, because floating point data information inside a computer is stored and represented in a binary manner (i.e., various codes composed of 0 and 1), but part of floating point data cannot be represented accurately in a binary manner, precision is easily lost during operation, calculation errors are caused, and calculation results are inaccurate. Aiming at the problem that the calculation result is inaccurate due to the loss of precision during the calculation of the floating point data, an effective solution is not provided at present.
Disclosure of Invention
The invention aims to provide a floating point data processing method and device in JavaScript operation and electronic equipment, which effectively improve the calculation accuracy of floating point data.
In a first aspect, an embodiment provides a method for processing floating point data in JavaScript operation, where the method includes: acquiring floating point data to be operated, and converting the floating point data to be operated into corresponding character string data; using decimal points of the character string data as mark bits to obtain decimal digits of the character string data; and converting the character string data into an integer to be operated corresponding to the floating point data to be operated based on the decimal number of the character string data, and operating based on the integer to be operated.
In an optional embodiment, the step of converting floating point data to be operated into corresponding character string data includes: converting floating point data to be operated into corresponding character string data based on a character string conversion function; the string translation function includes a toString function.
In an optional embodiment, the step of obtaining the decimal place of the character string data by using the decimal point of the character string data as a marker place includes: dividing character string data by using a character string dividing function and using decimal points as mark bits to obtain decimal places of the character string data; a decimal place of the character string data is obtained based on the decimal place.
In an alternative embodiment, the character string data includes at least first character string data and second character string data; the method comprises the following steps of converting character string data into an integer to be operated corresponding to floating point data to be operated based on decimal digits of the character string data, and comprises the following steps: determining the decimal digit of the first character string data as A, and determining the decimal digit of the second character string data as B; converting the first character string data based on the decimal number A of the first character string data to obtain a first integer; and converting the second floating point data based on the decimal number B of the second floating point data to obtain a second integer.
In an optional embodiment, the step of performing an operation based on the integer to be operated includes: and operating the first integer and the second integer according to a preset encapsulation function to obtain a target operation result.
In an alternative embodiment, the preset encapsulating functions include a multiplication encapsulating function, a division encapsulating function, an addition encapsulating function, and a subtraction encapsulating function; the multiplication packaging function comprises the steps of multiplying a first integer and a second integer to obtain a first intermediate operation result, and dividing the first intermediate operation result by a first reduction multiple; wherein the first reduction multiple is the product of A and B; the division packaging function comprises dividing the first integer and the second integer to obtain a second intermediate operation result, and dividing the second intermediate operation result by a second reduction multiple; wherein the second reduction factor is a subtracted value of A and B; the addition packing function comprises adding the first integer and the second integer to obtain a third intermediate operation result, and dividing the third intermediate operation result by a third reduction multiple; wherein the third reduction factor is the larger of A and B; the subtraction packaging function comprises subtracting the first integer and the second integer to obtain a fourth intermediate operation result, and dividing the fourth intermediate operation result by the third reduction multiple; the method comprises the following steps of operating a first integer and a second integer according to a preset encapsulation function to obtain a target operation result, wherein the steps comprise: determining an operation mode of operating the first integer and the second integer; the operation mode comprises multiplication, division, addition and subtraction; and calling the corresponding packaging function based on the operation mode to obtain a target operation result.
In a second aspect, an embodiment provides an apparatus for processing floating point data in JavaScript operation, where the apparatus includes: the data conversion module is used for acquiring floating point data to be operated and converting the floating point data to be operated into corresponding character string data; the decimal digit determining module is used for acquiring decimal digits of the character string data by taking decimal points of the character string data as mark bits; and the data operation module is used for converting the character string data into an integer to be operated corresponding to the floating point data to be operated based on the decimal number of the character string data and performing operation based on the integer to be operated.
In an optional embodiment, the data conversion module is configured to convert floating point data to be operated into corresponding character string data based on a character string conversion function; the string translation function includes a toString function.
In a third aspect, an embodiment provides an electronic device, including a processor and a memory; the memory has stored thereon a computer program which, when executed by the processor, performs the method according to any of the preceding embodiments.
In a fourth aspect, embodiments provide a computer readable storage medium for storing computer software instructions for a method according to any one of the preceding embodiments.
The method comprises the steps of obtaining floating point data to be operated, converting the floating point data to be operated into corresponding character string data, obtaining decimal digits of the character string data by taking decimal points of the character string data as marking bits, converting the character string data into integers to be operated corresponding to the floating point data to be operated based on the decimal digits of the character string data, and operating based on the integers to be operated. The decimal point is used as a mark bit to obtain a decimal fraction, floating point data to be operated are converted into integers to be operated on the basis of the decimal fraction, the reduction multiple is determined according to the expansion multiple converted into the integers after an intermediate result is obtained, and then a final operation result is obtained. Therefore, the embodiment of the invention effectively improves the calculation accuracy of the floating point data.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a schematic flow chart of a floating point data processing method in JavaScript operation according to an embodiment of the present invention;
fig. 2 is a schematic flow chart of another floating point data processing method in JavaScript operation according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a floating-point data processing apparatus in JavaScript operation according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device 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 in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
In the description of the present invention, it should be noted that the terms "first", "second", "third", and the like are used only for distinguishing the description, and are not intended to indicate or imply relative importance.
Some embodiments of the invention are described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
In view of the problem that the calculation result is often inaccurate due to precision loss in the operation of floating point data in the application of browser webpages, the embodiment of the invention provides a floating point data processing method in JavaScript operation, and the calculation accuracy of the floating point data is effectively improved.
For convenience of understanding, a method for processing floating point data in JavaScript operation according to an embodiment of the present invention is first described in detail, referring to a flow diagram of a method for processing floating point data in JavaScript operation shown in fig. 1, where the method mainly includes the following steps S102 to S106:
step S102: and acquiring floating point data to be operated, and converting the floating point data to be operated into corresponding character string data.
In one embodiment, the floating point data to be operated is floating point data to be calculated in the browser webpage application, and the floating point data to be operated is converted into corresponding character string data through a character string conversion function, such as a toString function in JavaScript, so that operation is convenient after the character string data is obtained.
Step S104: and acquiring decimal digits of the character string data by taking decimal points of the character string data as mark bits.
In an embodiment, the floating point data can be expanded by obtaining the decimal number of the floating point data to obtain a corresponding integer, so that the operation is performed, and since the precision of the integer is not lost, the accuracy of the calculation can be greatly improved. The character string segmentation function may adopt a split function in a JavaScript program language, for example, 1.25 may be divided into [ "1", "25" ] by using a decimal point as a marker bit through a code "1.25". split (") so as to obtain a decimal bit 25, and further obtain a digit number of 2, and obtain data arr [1]. length of 2 through arr [" 1 "," 25 "] so as to determine that the decimal digit number is 2.
Step S106: and converting the character string data into an integer to be operated corresponding to the floating point data to be operated based on the decimal number of the character string data, and operating based on the integer to be operated.
In an embodiment, through the obtained decimal digits, the character string data can be converted into an integer to be operated, the obtained decimal digit 2 is multiplied by the character string data by a power of 2 of 10 to obtain a corresponding integer, namely 125, and the obtained integer is used for operation, so that the problem of precision loss is effectively reduced, and the accuracy of calculation is improved.
The method for processing the floating point data in the JavaScript operation, provided by the invention, comprises the steps of obtaining the floating point data to be operated, converting the floating point data to be operated into corresponding character string data, taking a decimal point of the character string data as a mark bit, obtaining the decimal number of the character string data, converting the character string data into an integer to be operated corresponding to the floating point data to be operated based on the decimal number of the character string data, and operating based on the integer to be operated. The decimal point is used as a mark bit to obtain a decimal fraction, floating point data to be operated are converted into integers to be operated on the basis of the decimal fraction, the reduction multiple is determined according to the expansion multiple converted into the integers after an intermediate result is obtained, and then a final operation result is obtained. Therefore, the embodiment of the invention effectively improves the calculation accuracy of the floating point data.
To facilitate understanding of the step S106, an embodiment of the present invention further provides a specific implementation manner for converting, based on the decimal place of the character string data, the character string data into an integer to be operated corresponding to the floating point data to be operated, where the character string data at least includes a first character string data and a second character string data, and the step S106 may further include the following steps 1 and 2:
step 1, determining the decimal place number of the first character string data as A, and determining the decimal place number of the second character string data as B;
step 2, converting the first character string data based on the decimal number A of the first character string data to obtain a first integer; and converting the second floating point data based on the decimal number B of the second floating point data to obtain a second integer.
And 3, operating the first integer and the second integer according to a preset packaging function to obtain a target operation result.
For convenience of understanding, referring to a flow diagram of another floating point data processing method in JavaScript operation shown in fig. 2, the functions are encapsulated in JavaScript, and a program script file with a suffix of js is first created, and in the file, corresponding add, subtract, multiply, and divide functions are encapsulated in JavaScript program language, which are (add, sub, mul, div), respectively.
In one embodiment, multiplying the packing function includes multiplying the first integer and the second integer to obtain a first intermediate operation result, and dividing the first intermediate operation result by a first reduction factor; wherein the first reduction factor is the product of A and B. In practical application, a multiplication encapsulation function is defined as mul, a multiplier and a multiplicand decimal place number A and B of floating point data transmitted into the method are obtained firstly, A and B are converted into integer data through Math.pow, and data C obtained by adding A and B is obtained through an operator "+" of a JavaScript language (at the moment, C is a first reduction multiple). Pow converts the multiplier and multiplicand of floating point data into integers respectively, then multiplies the integers by an operator '. DELTA.in a JavaScript language to obtain a result D (at the moment, D is a first intermediate operation result), and divides C by the D power of 10 by the operator '/' in the JavaScript language to obtain an accurate multiplication result.
In one embodiment, the divide-by-package function includes dividing the first integer by the second integer to obtain a second intermediate result, and dividing the second intermediate result by a second reduction factor; in practical application, the divisor and dividend decimal digits of floating point data transmitted to the method are obtained first, the A and B are converted into integer data through Math.pow, and the value data C obtained by subtracting the A and B is obtained through an operator "-" of a JavaScript language (at this time, C is the second reduction multiple). Pow obtains 10C power result G, the first integer and the second integer are divided by an operator '/' of JavaScript language to obtain a result D, and the G and the D are multiplied by the packed multiplication function, so that an accurate division result is obtained.
In one embodiment, the addition packing function includes adding the first integer and the second integer to obtain a third intermediate operation result, and dividing the third intermediate operation result by a third reduction factor; wherein the third reduction factor is the larger of a and B. Encapsulating add addition function, firstly obtaining addend and addend decimal digit numbers A and B of floating point number data transmitted into the method, obtaining maximum number C in A and B through Math.max in JavaScript language api (at this time, C is a third reduction multiple), obtaining base number D of C power of 10 through Math.pow (at this time, D is a third intermediate operation result), amplifying the addend of the floating point number data and the mul method encapsulated by the addend by D times, adding to obtain E, and dividing the E by the D multiple through an operator '/' of JavaScript language, thereby obtaining an accurate addition result.
In one embodiment, the subtraction packing function includes subtracting the first integer and the second integer to obtain a fourth intermediate operation result, and dividing the fourth intermediate operation result by the third reduction factor. Packaging a sub subtraction function, firstly obtaining the decimal digits A and B of the subtracted number and the subtracted number of the floating point number data transmitted into the method, obtaining the maximum number C (at the moment, C is a third reduction multiple) in the A and the B through Math.max in JavaScript language api, obtaining the basic number D (at the moment, D is a fourth intermediate operation result) of the C power of 10 through Math.pow, converting the subtracted number and the subtracted number of the floating point number data into integers, subtracting the integers to obtain E, and dividing the E by the D multiple through an operator '/' of the JavaScript language, thereby obtaining an accurate subtraction result.
Step 3 may further comprise step 3.1 and step 3.2:
and 3.1, determining an operation mode of operating the first integer and the second integer, wherein the operation mode can comprise multiplication, division, addition and subtraction.
And 3.2, calling the corresponding packaging function based on the operation mode to obtain a target operation result. And after the operation mode is determined, calling a corresponding operation encapsulation function to obtain a target operation result obtained after the initial floating point data to be operated are calculated.
For floating point data processing in JavaScript operation provided in the above embodiment, an embodiment of the present invention further provides a floating point data processing apparatus in JavaScript operation, referring to a schematic structural diagram of the floating point data processing apparatus in JavaScript operation shown in fig. 3, where the apparatus mainly includes:
the data conversion module 302 is configured to obtain floating point data to be operated, and convert the floating point data to be operated into corresponding character string data;
a decimal digit determining module 304, configured to obtain a decimal digit of the character string data by using a decimal point of the character string data as a mark bit;
and the data operation module 306 is configured to convert the character string data into an integer to be operated corresponding to the floating point data to be operated based on the decimal number of the character string data, and perform operation based on the integer to be operated.
The floating point data processing device in JavaScript operation provided by the invention obtains the floating point data to be operated, converts the floating point data to be operated into the corresponding character string data, obtains the decimal number of the character string data by taking the decimal point of the character string data as a mark bit, converts the character string data into the integer to be operated corresponding to the floating point data to be operated based on the decimal number of the character string data, and operates based on the integer to be operated. The decimal point is used as a mark bit to obtain a decimal fraction, floating point data to be operated are converted into integers to be operated on the basis of the decimal fraction, the reduction multiple is determined according to the expansion multiple converted into the integers after an intermediate result is obtained, and then a final operation result is obtained. Therefore, the embodiment of the invention effectively improves the calculation accuracy of the floating point data.
In an embodiment, the data conversion module 302 is further configured to convert floating point data to be operated into corresponding character string data based on a character string conversion function; the string translation function includes a toString function.
In an embodiment, the decimal place number determining module 304 is further configured to perform segmentation on the character string data by using a character string segmentation function and using a decimal point as a mark bit to obtain a decimal place of the character string data; a decimal place of the character string data is obtained based on the decimal place.
In an embodiment, the character string data at least includes a first character string data and a second character string data, and the data operation module 306 is further configured to determine the decimal place number of the first character string data as a, and the decimal place number of the second character string data as B; converting the first character string data based on the decimal number A of the first character string data to obtain a first integer; and converting the second floating point data based on the decimal number B of the second floating point data to obtain a second integer.
In one embodiment, the above apparatus further comprises: and the second operation module is used for operating the first integer and the second integer according to a preset packaging function to obtain a target operation result.
In one embodiment, the preset encapsulating functions include a multiplication encapsulating function, a division encapsulating function, an addition encapsulating function and a subtraction encapsulating function; the multiplication packaging function comprises the steps of multiplying a first integer and a second integer to obtain a first intermediate operation result, and dividing the first intermediate operation result by a first reduction multiple; wherein the first reduction multiple is the product of A and B; the division packaging function comprises dividing the first integer and the second integer to obtain a second intermediate operation result, and dividing the second intermediate operation result by a second reduction multiple; wherein the second reduction factor is a subtracted value of A and B; the addition packing function comprises adding the first integer and the second integer to obtain a third intermediate operation result, and dividing the third intermediate operation result by a third reduction multiple; wherein the third reduction factor is the larger of A and B; the subtraction packaging function comprises subtracting the first integer and the second integer to obtain a fourth intermediate operation result, and dividing the fourth intermediate operation result by the third reduction multiple; the second operation module is further configured to determine an operation manner for operating the first integer and the second integer; the operation mode comprises multiplication, division, addition and subtraction; and calling the corresponding packaging function based on the operation mode to obtain a target operation result.
The device is an electronic device, and particularly, the electronic device comprises a processor and a storage device; the storage means has stored thereon a computer program which, when executed by the processor, performs the method of any of the above described embodiments.
Fig. 4 is a schematic structural diagram of an electronic device 100 according to an embodiment of the present invention, where the electronic device 100 includes: a processor 40, a memory 41, a bus 42 and a communication interface 43, wherein the processor 40, the communication interface 43 and the memory 41 are connected through the bus 42; the processor 40 is arranged to execute executable modules, such as computer programs, stored in the memory 41.
The memory 41 may include a high-speed Random Access Memory (RAM) and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. The communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 43 (which may be wired or wireless), and the internet, a wide area network, a local network, a metropolitan area network, etc. may be used.
The bus 42 may be an ISA bus, PCI bus, EISA bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 4, but that does not indicate only one bus or one type of bus.
The memory 41 is used for storing a program, the processor 40 executes the program after receiving an execution instruction, and the method executed by the apparatus defined by the flow process disclosed in any of the foregoing embodiments of the present invention may be applied to the processor 40, or implemented by the processor 40.
The processor 40 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 40. The processor 40 may be a general-purpose processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory 41, and the processor 40 reads the information in the memory 41 and completes the steps of the method in combination with the hardware thereof.
The floating point data processing method and device in JavaScript operation and the computer program product of the electronic device provided in the embodiments of the present invention include a computer readable storage medium storing a non-volatile program code executable by a processor, where a computer program is stored on the computer readable storage medium, and when the computer program is executed by the processor, the method described in the foregoing method embodiments is executed.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working process of the system described above may refer to the corresponding process in the foregoing embodiments, and is not described herein again.
The computer program product of the readable storage medium provided in the embodiment of the present invention includes a computer readable storage medium storing a program code, where instructions included in the program code may be used to execute the method described in the foregoing method embodiment, and specific implementation may refer to the method embodiment, which is not described herein again.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1. A floating point data processing method in JavaScript operation is characterized by comprising the following steps:
acquiring floating point data to be operated, and converting the floating point data to be operated into corresponding character string data;
using the decimal point of the character string data as a mark bit to obtain the decimal number of the character string data;
converting the character string data into an integer to be operated corresponding to the floating point data to be operated based on the decimal number of the character string data, and operating based on the integer to be operated.
2. The method according to claim 1, wherein the step of converting the floating point data to be operated on into corresponding character string data comprises:
converting the floating point data to be operated into corresponding character string data based on a character string conversion function; the string translation function comprises a toString function.
3. The method according to claim 1, wherein the step of obtaining the decimal place of the character string data by using the decimal place of the character string data as a marker bit comprises:
dividing the character string data by using a character string dividing function and using decimal points as mark bits to obtain decimal places of the character string data;
and acquiring decimal digits of the character string data based on the decimal digits.
4. The method according to claim 1, wherein the character string data includes at least first character string data and second character string data; the step of converting the character string data into an integer to be operated corresponding to the floating point data to be operated based on the decimal place of the character string data includes:
determining the decimal place number of the first character string data as A, and determining the decimal place number of the second character string data as B;
converting the first character string data based on the decimal digit A of the first character string data to obtain a first integer; and converting the second character string data based on the decimal digit B of the second character string data to obtain a second integer.
5. The method according to claim 4, wherein the step of operating based on the integer to be operated comprises:
and operating the first integer and the second integer according to a preset encapsulation function to obtain a target operation result.
6. The method of claim 5, wherein the preset packing functions include multiply packing function, divide packing function, add packing function, and subtract packing function;
the multiplication packaging function comprises multiplying the first integer and the second integer to obtain a first intermediate operation result, and dividing the first intermediate operation result by a first reduction multiple; wherein the first reduction factor is the product of the A and the B;
the division packaging function comprises dividing the first integer and the second integer to obtain a second intermediate operation result, and dividing the second intermediate operation result by a second reduction multiple; wherein the second reduction factor is a subtracted value of the A and the B;
the addition packing function comprises adding the first integer and the second integer to obtain a third intermediate operation result, and dividing the third intermediate operation result by a third reduction multiple; wherein the third reduction factor is the larger of the values of A and B;
the subtraction packaging function comprises subtracting the first integer and the second integer to obtain a fourth intermediate operation result, and dividing the fourth intermediate operation result by the third reduction multiple;
the step of operating the first integer and the second integer according to a preset encapsulation function to obtain a target operation result includes:
determining an operation mode of operating the first integer and the second integer; the operation mode comprises multiplication, division, addition and subtraction;
and calling a corresponding packaging function based on the operation mode to obtain the target operation result.
7. An apparatus for processing floating point data in JavaScript operation, the apparatus comprising:
the data conversion module is used for acquiring floating point data to be operated and converting the floating point data to be operated into corresponding character string data;
the decimal digit determining module is used for acquiring the decimal digit of the character string data by taking the decimal point of the character string data as a mark bit;
and the data operation module is used for converting the character string data into an integer to be operated corresponding to the floating point data to be operated based on the decimal number of the character string data and performing operation based on the integer to be operated.
8. The apparatus of claim 7, wherein the data conversion module is configured to convert the floating point data to be operated on into corresponding string data based on a string conversion function; the string translation function comprises a toString function.
9. An electronic device comprising a processor and a memory;
the memory has stored thereon a computer program which, when executed by the processor, performs the method of any of claims 1 to 6.
10. A computer readable storage medium for storing computer software instructions for use in the method of any one of claims 1 to 6.
CN201911297808.XA 2019-12-16 2019-12-16 Floating point data processing method and device in JavaScript operation and electronic equipment Pending CN111078188A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911297808.XA CN111078188A (en) 2019-12-16 2019-12-16 Floating point data processing method and device in JavaScript operation and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911297808.XA CN111078188A (en) 2019-12-16 2019-12-16 Floating point data processing method and device in JavaScript operation and electronic equipment

Publications (1)

Publication Number Publication Date
CN111078188A true CN111078188A (en) 2020-04-28

Family

ID=70314910

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911297808.XA Pending CN111078188A (en) 2019-12-16 2019-12-16 Floating point data processing method and device in JavaScript operation and electronic equipment

Country Status (1)

Country Link
CN (1) CN111078188A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112506935A (en) * 2020-12-21 2021-03-16 北京百度网讯科技有限公司 Data processing method, data processing apparatus, electronic device, storage medium, and program product
CN113326048A (en) * 2021-06-24 2021-08-31 上海万向区块链股份公司 Floating point number calculation precision processing method, system, medium and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030126174A1 (en) * 2001-12-28 2003-07-03 Fujitsu Limited Apparatus and method of performing product-sum operation
US7644115B2 (en) * 2005-01-07 2010-01-05 Sas Institute Inc. System and methods for large-radix computer processing
CN105404494A (en) * 2015-12-18 2016-03-16 苏州中晟宏芯信息科技有限公司 Floating point fusion multiplication and addition method based on interior forward-push, apparatus and processor
CN107391463A (en) * 2017-07-20 2017-11-24 上海金大师网络科技有限公司 A kind of market data compression method and system
CN109960532A (en) * 2017-12-22 2019-07-02 航天信息股份有限公司 Method and device for front stage operation

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030126174A1 (en) * 2001-12-28 2003-07-03 Fujitsu Limited Apparatus and method of performing product-sum operation
US7644115B2 (en) * 2005-01-07 2010-01-05 Sas Institute Inc. System and methods for large-radix computer processing
CN105404494A (en) * 2015-12-18 2016-03-16 苏州中晟宏芯信息科技有限公司 Floating point fusion multiplication and addition method based on interior forward-push, apparatus and processor
CN107391463A (en) * 2017-07-20 2017-11-24 上海金大师网络科技有限公司 A kind of market data compression method and system
CN109960532A (en) * 2017-12-22 2019-07-02 航天信息股份有限公司 Method and device for front stage operation

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
佚名: "js浮点数的计算", 《HTTPS://WWW.CNBLOGS.COM/DAISYWANG/P/5827914.HTML》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112506935A (en) * 2020-12-21 2021-03-16 北京百度网讯科技有限公司 Data processing method, data processing apparatus, electronic device, storage medium, and program product
CN112506935B (en) * 2020-12-21 2023-08-29 北京百度网讯科技有限公司 Data processing method, device, electronic equipment, storage medium and program product
CN113326048A (en) * 2021-06-24 2021-08-31 上海万向区块链股份公司 Floating point number calculation precision processing method, system, medium and device

Similar Documents

Publication Publication Date Title
US10127014B2 (en) Round for reround mode in a decimal floating point instruction
US6976043B2 (en) Technique for approximating functions based on lagrange polynomials
CN111078188A (en) Floating point data processing method and device in JavaScript operation and electronic equipment
US10430182B2 (en) Enhanced compression, encoding, and naming for resource strings
US9467166B2 (en) Enhanced compression, encoding, and naming for resource strings
CN111813371B (en) Floating point division operation method, system and readable medium for digital signal processing
US10467001B2 (en) Enhanced compression, encoding, and naming for resource strings
CN112241291A (en) Floating point unit for exponential function implementation
CN110647718A (en) Data processing method, device, equipment and computer readable storage medium
US9143159B2 (en) DPD/BCD to BID converters
US9886442B2 (en) Enhanced compression, encoding, and naming for resource strings
US10013258B2 (en) Single instruction array index computation
CN109756231B (en) Cyclic shift processing device and method
US8078658B2 (en) ASCII to binary decimal integer conversion in a vector processor
CN113625990B (en) Floating point-to-fixed point device, method, electronic equipment and storage medium
JP2018097864A (en) Leading zero anticipation
JP2018195956A (en) Encoding program, encoding device and encoding method
CN113296827A (en) Method and device for converting different languages and terminal equipment
CN109857991B (en) Data storage method and device and electronic equipment
CN111538474A (en) Division and evolution operation processor and operation processing system of Posit floating point number
CN112445525B (en) Data processing method, related equipment and computer readable medium
CN113064841B (en) Data storage method, processing method, computing device and readable storage medium
CN116150142B (en) Method, device, medium, equipment and product for field verification and rule obtaining thereof
CN117540669B (en) Method and device for processing structured data of digital circuit
CN117785388B (en) Method, device, medium and equipment for generating pseudo random sequence calculation program

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200428