Can anyone please tell me the difference between ALT and SLT?
Another thing: how SRA instruction works with shamt?
Reference: https://web.archive.org/web/20201111203150/http://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html
SRA is an arithmetic right shift, meaning that it shifts in the original sign bit rather than zeroes.
For example:
li $t0,0x80000000
sra $t0,$t0,4
# $t0 now contains 0xF8000000
li $t0,0x40000000
sra $t0,$t0,4
# $t0 now contains 0x04000000
Related
I'm trying to search for a pattern and if it repeats 2nd time, delete to end of line..., please help.
For that using I'm using :%s/my_character.*//g, but this will work for the 1st occurrence of the character in a line, but I need it from 2nd occurrence in the line...
Not sure if I understand it well (you should give a plain example, it always makes it clearer)
I would do it like this:
:s/^\(.\{-}my_character.\{-}\)my_character.*$/\1/
This will search for:
As few character as possible before my_character
my_character
As few character as possible before the second my_character
my_character
Any character
And replace it with characters captured from 1 to 3 in the steps above.
Example:
Input:
werklj z sdkl Azlksd er.
search and replace:
:s/^\(.\{-}z.\{-}\)z.*$/\1/
Output:
werklj z sdkl A
I have been trying to read a file which has date field and a numeric field. I have the data in an excel sheet and looks something like below -
Date X
1/25/2008 0.0023456
12/23/2008 0.001987
When I read this in R using the readxl::read_xlsx function, the data in R looks like below -
Date X
1/25/2008 0.0023456000000000
12/23/2009 0.0019870000000000
I have tried limiting the digits using functions like round, format (nsmall = 7), etc. but nothing seems to work. What am I doing wrong? I also tried saving the data as a csv and a txt and read it using read.csv and read.delim but I face the same issue again. Any help would be really appreciated!
As noted in the comments to the OP and the other answer, this problem is due to the way floating point math is handled on the processor being used to run R, and its interaction with the digits option.
To illustrate, we'll create an Excel spreadsheet with the data from the OP, and demonstrate what happens as we adjust the options(digits=) option.
Next, we'll write a short R script to illustrate what happens when we adjust the digits option.
> # first, display the number of significant digits set in R
> getOption("digits")
[1] 7
>
> # Next, read data file from Excel
> library(xlsx)
>
> theData <- read.xlsx("./data/smallNumbers.xlsx",1,header=TRUE)
>
> head(theData)
Date X
1 2008-01-25 0.0023456
2 2008-12-23 0.0019870
>
> # change digits to larger number to replicate SO question
> options(digits=17)
> getOption("digits")
[1] 17
> head(theData)
Date X
1 2008-01-25 0.0023456000000000002
2 2008-12-23 0.0019870000000000001
>
However, the behavior of printing significant digits varies by processor / operating system, as setting options(digits=16) results in the following on a machine running an Intel i7-6500U processor with Microsoft Windows 10:
> # what happens when we set digits = 16?
> options(digits=16)
> getOption("digits")
[1] 16
> head(theData)
Date X
1 2008-01-25 0.0023456
2 2008-12-23 0.0019870
>
library(formattable)
x <- formattable(x, digits = 7, format = "f")
or you may want to add this to get the default formatting from R:
options(defaultPackages = "")
then, restart your R.
Perhaps the problem isn't your source file as you say this happens with .csv and .txt as well.
Try checking to see the current value of your display digits option by running options()$digits
If the result is e.g. 14 then that is likely the problem.
In which case, try running r command options(digits=8) which will set the display digits=8 for the session.
Then, simply reprint your dataframe to see the change has already taken effect with respect to how the decimals are displayed by default to the screen.
Consult ?options for more info about digits display setting and other session options.
Edit to improve original answer and to clarify for future readers:
Changing options(digits=x) either up or down does not change the value that is stored or read into into internal memory for floating point variables. The digits session option merely changes how the floating point values print i.e. display on the screen for common print functions per the '?options` documentation:
digits: controls the number of significant digits to print when printing numeric values.
What the OP showed as the problem he was having (R displaying more decimals after last digit in a decimal number than the OP expected to see) was not caused by the source file having been read from Excel - i.e. given the OP had the same problem with CSV and TXT the import process didn't cause a problem.
If you are seeing more decimals than you want by default in your printed/displayed output (e.g. for dataframes and numeric variables) try checking options()$digits and understand that option is simply the default for the number of digits used by R's common display and printing methods. HOWEVER, it does not affect floating point storage on any of your data or variables.
Regarding floating point numbers though, another answer here shows how setting option(digits=n) higher than the default can help demonstrate some precision/display idiosyncrasies that are related to floating point precision. That is a separate problem to what the OP displayed in his example but it's well worth understanding.
For a much more detailed and topic specific discussion of floating point precision than would be appropriate to rehash here, it's well worth reading this definitive SO question+answer: Why are these numbers not equal?
That other question+answer+discussion covers issues specifically around floating point precision and contains a long, well presented list of references that you will find helpful if you need more information on the subject.
Is it possible to include code in my script that will set the cursor back to the start of the current line as it prints output in the REPL? (i.e. so that what the user sees gets updated). I tried \r in #printf but it seems to do the same as \n.
So far the only solution I found is to #printf several \b characters:
julia> #printf("one\ntwo\rthree")
one
two
three
julia> #printf("one\ntwo\b\bhree")
one
three
julia>
Is there a better way to set the cursor to the beginning of the current line? I am on a Windows system.
You might have encountered a bug in the #printf macro. I just tried your example, and it now works fine -- i.e. it works as you expected it to work, the output two is now overwritten by three:
julia> #printf "one\ntwo\rthree"
one
three
This works on a mac and linux. Not sure though about windows.
for idx = 1:10
sleep(1)
#printf("\tSeconds Passed =%d%s", idx, '\r')
end
The #printf help says that it uses C style formatting, so this response was based on that. The \t at the beginning is just to make the output a bit easier to see.
Is there any explanation docs or tutorials of the file structure of FreeDict, Aspell, Hunspell/OpenOffice Dictionaries especially concerning the switches at the end of each row in each .dic file? My guess is that the switches describe the semantic interpretation of the word whether it's a
noun
adjective
adverb
adverbial
etc.
or any combination of the above. But I don't know how to match these to the switch characters.
I'm also curios about what the .aff file describes.
This looks like a good starting point, and the downloads at this page may have the format documentation you're looking for.
Just a couple of links that might help you:
this is on sthackoverflow :
What's the format of the OpenOffice dictionaries?
this second one is a good start
http://sourceforge.net/apps/mediawiki/freedict/index.php?title=Main_Page
hope this helps
In Hunspell the tags you choose are arbitrary, they have no meaning other than that which you assign to them. You can choose from using letters, numbers (1-65535) and more.
The affix file describes many things, but is mainly concerned with how words are inflected.
For example:
$ test.dic
4
apple/a
banana/a
green/b
small/b
$ test.aff
SFX a Y 2 # Allow the following 2 suffixes to words with the "a" flag.
SFX a 0 s . # An "s" at the end for words ending in any letter (signified by the dot). "Apples" and "bananas".
SFX a 0 s' . # "Apples'" and "bananas'".
SFX b Y 2
SFX b 0 er . # "Greener" and "smaller".
SFX b 0 est . # "Greenest" and "smallest".
The manual explains most of the things in detail. There are also test files one can look at.
The code in my Zsh
#!/bin/zsh
q=$1
open "http://mathworld.wolfram.com/$q.html"
I put the input to the app
triangle
I get an error at Wolfram, since the first letter must be a big one.
How can you change the case for the first letter in the variable q?
# q=triangle
# echo ${(C)q}
Triangle
See Parameter Expansion Flags.