notation

1e-9 or -1e9, which one is correct? [closed]

匆匆过客 提交于 2019-12-02 21:59:35
I am assigned some old code and when I was reading through it, I noticed it had these in the form of: float low = 1e-9; float high = 1e9; float lowB = 1e-9; float highB = 1e9; float lowL = 1e-9; float highL = 1e9; So I see that it's trying to define some ranges using the e notation, right? But isn't 1e-9 supposed to be -1e9 ? Then the values would be between -1000000000 and 1000000000 , right? I am not sure what 1e-9 is meant for? Neither is more correct than the other. They just represent different values. 1e-9 is 0.000000001 ; the minus sign applies to the exponent. -1e9 is -1000000000.0 ;

Why is the dereference operator (*) also used to declare a pointer?

这一生的挚爱 提交于 2019-12-02 16:31:38
I'm not sure if this is a proper programming question, but it's something that has always bothered me, and I wonder if I'm the only one. When initially learning C++, I understood the concept of references, but pointers had me confused. Why, you ask? Because of how you declare a pointer. Consider the following: void foo(int* bar) { } int main() { int x = 5; int* y = NULL; y = &x; *y = 15; foo(y); } The function foo(int*) takes an int pointer as parameter. Since I've declared y as int pointer, I can pass y to foo , but when first learning C++ I associated the * symbol with dereferencing, as such

Syntax for documenting JSON structure

南楼画角 提交于 2019-12-02 16:28:37
So I'm trying to document the format of the json returned by an api I am writing against and I'd like to know if there is any popular format for the documentation of json structure. Note I'm not trying to to test or validate anything, I'm just using this for documentation. Also some ways to add comments to non-constants(items always returned w/ the same value) would be nice. This the not totally thought out scheme I'm currently using: Plain names refer to identifiers or types. Some types have type-comment Strings that appear to be constant(always returned for that type of request) strings are

Null-condition and null-coalescing operator *vs.* plain boolean notation

ε祈祈猫儿з 提交于 2019-12-02 16:11:38
问题 Example 1: var ca = p.GetCustomAttribute<ConnectorAttribute>(); return ca?.Point.IsEqual(cp) ?? false; Example 2: var ca = p.GetCustomAttribute<ConnectorAttribute>(); return (null != ca) && ca.Point.IsEqual(cp); Question: Does the two example return the same result? Which one performs better? Are there any concerns about thread safety? Edit: Nobody mention but the title had some error, I've corrected it. Edit 2: According the comments, 'those code are the same'. For me it is still not as

Null-condition and null-coalescing operator *vs.* plain boolean notation

非 Y 不嫁゛ 提交于 2019-12-02 08:26:00
Example 1: var ca = p.GetCustomAttribute<ConnectorAttribute>(); return ca?.Point.IsEqual(cp) ?? false; Example 2: var ca = p.GetCustomAttribute<ConnectorAttribute>(); return (null != ca) && ca.Point.IsEqual(cp); Question: Does the two example return the same result? Which one performs better? Are there any concerns about thread safety? Edit: Nobody mention but the title had some error, I've corrected it. Edit 2: According the comments, 'those code are the same'. For me it is still not as trivial as it seams to be. The answer here tells that the first part of example 1. creates a Nullable<bool>

How to convert a BigInteger to a scientific notation string and back?

社会主义新天地 提交于 2019-12-02 07:01:30
问题 I want to convert BigInteger number into a small scientific notation like 1.86e+6 and again reconvert that scientific notation into BigInteger number in Java. Please help. 回答1: The easiest way is to use a BigDecimal to parse or output the scientific notation string. You can can do something like: BigDecimal bd = new BigDecimal("1.86E+6"); BigInteger bi = bd.toBigInteger(); and reverse: bd = new BigDecimal(bi); String s = bd.toString(); Update If you need more user-defined output, then you can

postfix 'd+0' in Fortran real literal expressions

独自空忆成欢 提交于 2019-12-02 03:19:37
问题 Does anyone knwow what the postfix " d+0 " means in the assignments to M1, M2 and M4 below or is there any resource on the web or a book where one is very likely to find this information? subroutine plot( t, x, p, q, nga, nt, wron, & ngq, gq, ngaq1, ngaq2, gaq, rwh, iwh ) implicit none integer*4 nga, nt, ngq, ngaq1, ngaq2, iwh(*) real*8 t, x(*), p(*), q(*), wron(nga,*), & gq(ngq,*), gaq(ngaq1,ngaq2,*), rwh(*) real*8 M1, M2, M3, M4, mr, mst, h3, Tc integer*8 iflag c DISCRETIZE1( Tc, rwh, iwh )

Force R to write scientific notations as n.nn x 10^-n with superscript

僤鯓⒐⒋嵵緔 提交于 2019-12-02 01:14:32
问题 Let's say I have two floats a <- 8.9384920e-24 b <- 0.00293892837 I would like to display either of them in 10-base scientific notation rounded to two decimals on a graph, possibly using paste() , but with superscript formatting after the 10. 8.94 x 10^-24 #no ^ and superscript font 2.94 x 10^-4 #no ^ and supercript font, should be -4, not -04 This is really maniac but it has been requested by a superior, it has to be done in base R (not ggplot2) or I will have to re-write 600 lines of code..

Force R to write scientific notations as n.nn x 10^-n with superscript

喜夏-厌秋 提交于 2019-12-01 20:54:07
Let's say I have two floats a <- 8.9384920e-24 b <- 0.00293892837 I would like to display either of them in 10-base scientific notation rounded to two decimals on a graph, possibly using paste() , but with superscript formatting after the 10. 8.94 x 10^-24 #no ^ and superscript font 2.94 x 10^-4 #no ^ and supercript font, should be -4, not -04 This is really maniac but it has been requested by a superior, it has to be done in base R (not ggplot2) or I will have to re-write 600 lines of code... Right now all I can see is that floats are printed differently depending on how big they are... You

How can I convert between scientific and decimal notation in Perl?

烂漫一生 提交于 2019-12-01 18:09:05
I know this is a total newbie question, but the answer may not be obvious to many new programmers. It wasn't initially obvious to me so I scoured the Internet looking for Perl modules to do this simple task. Kurt W. Leucht sprintf does the trick use strict; use warnings; my $decimal_notation = 10 / 3; my $scientific_notation = sprintf("%e", $decimal_notation); print "Decimal ($decimal_notation) to scientific ($scientific_notation)\n\n"; $scientific_notation = "1.23456789e+001"; $decimal_notation = sprintf("%.10g", $scientific_notation); print "Scientific ($scientific_notation) to decimal (