Parsing Scientific Notation in dynamic-expresso - dynamic-expresso

Just wondering why parsing of scientific notation was not implemented. I was able to add it with a few simple functions using RegularExpressions. The code scrubs the expression string to replace scientific expression values with double strings prior to evaluation.
Ex)
"SomeVar<=5.5e-3" becomes: "SomeVar<=0.0055"
"SomeOtherVar>=-9.9E4" becomes: "SomeOtherVar>=-99000"
I will add it if anyone is interested.

Related

bigquery Convert oct/hex/dec codes to its text equivalent

In my bigquery table i have some string values that for some unkown reason to me show up like;
BIQUÃ\215NI or BRASÃ\u008dLIA.
I know Ã\215 and Ã\u008d are equivalent to "Í", but i can't find a way to convert them to i'ts equivalent inside my query, i don't want to do a replace for each value that appears like that inside my bank, and i can't find a way to convert them to it's text equivalent inside bigquery documentation.
I already tried FORMAT('%o', 215) but it only converts octal to byte and it only work`s with numeric tables.
I tried REGEXP_REPLACE too but can`t find a way to refer to all octal forms inside the strings.
By using this online tool, Ã\215 and Ã\u008d are equivalent to "Í". But when you put in BigQuery, both gave an "Ã" value as it reads à only and both \215 and \u008d are not used or simply don't have an equivalent.
The CAST() function can be simply used in converting these UTF-8 encoded values, but the query reads ISO 8859-1(Latin-1) Unicode Mappings, and as I stated earlier, it will only return a null value.
My take on this case, you can convert first using the tool that I mentioned, and find the right Unicode Hex in unicode mappings.
SELECT CAST('BIQU\u00cdNI' AS STRING) AS Converted
Whereas, \u00cd is equivalent to Í.

Remove scientific notation representation from a number of type double in C# and WPF

I am working with WPF and C# backend. I am having unit conversion package which converts from an inch to mm. All the values in this conversion are double. On UI, once I'm writing "0.000039", it is getting converted into scientific notation as soon as I type '3' of the above value and it is appending '9' to the scientific notation value. To get rid of this I want to remove scientific notation representation of numbers with a double datatype. How to do this? Please help.

OpenOffice Calc numeric formatting language

I am trying to display always-signed integers ('-1', '+4', etc: I'll even accept '+0') in OpenOffice Calc. I've had trouble finding exact information on the numeric formatting language used.
=TEXT(cellref;"#0")
doesn't display '+', and using "+#0" always displays '+' (it displays '-+3' for -3 in fact.)
Is there a format code for this, or do I have to write a function to handle the cases?
Here is a short but cryptic solution:
=TEXT(cellref;"\+#;\-#;0")
This is actually a three-part format code. It adds either a plus sign \+# for positive numbers, a minus sign \-# for negative numbers, or just a plain 0 for zeroes.
The syntax is described here: https://help.libreoffice.org/5.2/Common/Number_Format_Codes#Positive_and_Negative_Numbers
Another approach is to apply custom formatting, which is generally a good idea where numbers are involved, to make calculations with them easier:
"+"#;"-"#;0;General

How to format Standard ML print output?

I am trying to format some output in Standard ML. I need to display some real values as rounded to a certain decimal place, and I also need to be able to display some real values using scientific notation.
The signature for the print function is
val it = fn : string -> unit
which doesn't seem to allow for the use of formatting codes or any other parameters. I also haven't had any luck finding documentation online. Ideally I was hoping the print function in SML would have similar functionality to printf in C...
Standard ML is a statically-typed language. It's hard to make something like printf in a type-safe way.
The SML Basis Library contains some formatting operations for numbers. But to use them is relatively verbose and relatively difficult to figure out. For example, to format a real number into a string in scientific notation with 3 places after the decimal point, you can do something like this:
Real.fmt (StringCvt.SCI (SOME 3)) 4324423423.5; (* evaluates to string "4.324E9" *)
Ugly, right?
Some implementations offer other formatting methods. For example, SML/NJ has a Format structure that allows you to use a printf-style formatting string. However, the arguments must be wrapped according to their type:
Format.format "%.3e" [Format.REAL 4324423423.5]; (* evaluates to string "4.324e09" *)
Other SML implementations might have their own custom formatting functions.

When is it necessary to convert data types in Visual Basic 2010

Visual Basic 2010 (Express). I can best give this by example...
If I take a string from a textbox and assign it to an integer variable, I'm under the impression that you're supposed to use CInt to explicitly convert the contents to an integer.
intMyCount = CInt(txtUserInput.Text)
However, if I don't do that, it still seems to work. Similarly, if I have an integer and concatenate it into a label's text property, it still works:
lblResults.Text = intMyCount & " number of times."
rather than using intMyCount.ToString.
Why does it work? Is VB doing implicit conversions when possible? Are there examples where not explicitly converting with .ToString or using CInt would cause unexpected results?
This is done using late-binding, and it's dangerous because if the conversion ever fails (and there's lots of cases where your first example could fail) it ends up in an exception at runtime. To get the compiler to enforce safer casting, turn Option Strict On.
Additionally, most of the time you don't want to use CInt() to convert your string to int. Instead, prefer Integer.Parse() or Integer.TryParse().
Some languages handle string concatenation easily like this for the non-casting to string. Some also handle non-casting to numeric types to do calculations. Some languages don't handle it at all. However as a best-practice, I would always cast the variable to the type you want to avoid issues with improper input types.