Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
45
rated 0 times [  49] [ 4]  / answers: 1 / hits: 74376  / 6 Years ago, thu, june 21, 2018, 12:00:00

FJCVTZS is "Floating-point Javascript Convert to Signed fixed-point, rounding toward Zero". It is supported in Arm v8.3-A chips and later. Which is odd, because you don't expect to see JavaScript so close to the bare metal.


I can find explanations of what the instruction does, but not why it exists. This thread says "it exists as a single instruction is because JS's lack of an integer type means certain use cases need this operation obscenely often for no good algorithmic reason.". That's plausible but I would like a more detailed understanding.


More From » assembly

 Answers
17

It is because JS uses double precision for the numbers, but if you want to perform operations with bits, the task is nontrivial, so a specific instruction to convert JS double into integer makes the thing easier.


This ARM link explains it very well: https://community.arm.com/processors/b/blog/posts/armv8-a-architecture-2016-additions


In order to add more information regarding fuz's comment, the differences between FCVTZS and FJCVTZS (both of them convert floating point to int) are that in case of overflow, FJCVTZS value will be 0x80000000 instead of overflowing. Furthermore, FJCVTZS can generate an exception in order to indicate how the conversion was (i.e. inexact).


FJCVTZS : http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0801g/hko1477562192868.html


FCVTZS : http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0802a/FCVTZS_float_int.html


[#54151] Monday, June 18, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aidanl

Total Points: 156
Total Questions: 102
Total Answers: 112

Location: Saint Lucia
Member since Wed, Feb 8, 2023
1 Year ago
;