Character array is missing „e“ notation exponential mark

In my previous article about Fuzzing in Java, I encountered an interesting NumberFormatException: „Character array is missing „e“ notation exponential mark“. That one sparked a lot of curiosity. Today, let’s take a closer look at what exactly this error message means.

What Does This NumberFormatException Mean?

Let’s start with a simplified version of a method, dollar2euro, which converts a USD input to EUR:

Now, suppose we call this method using the string "뤇皽" as input.
This would produce the following error:

Input: 뤇皽
java.lang.NumberFormatException: Character 뤇 is neither a decimal digit number, decimal point, nor "e" notation exponential mark.

The message tells us that the character 뤇 is neither a decimal digit, a decimal point, nor an „e“ used in exponential notation. In mathematics and programming, exponential notation expresses numbers like 1e3 to represent 1000 compactly. Java expects input strings for BigDecimal to contain only valid number representations — digits, decimal points, or the character e for exponents.

Since „뤇“ is none of these, Java immediately throws a NumberFormatException.

How Can You Avoid This Error?

To prevent this error, we should ensure that the value passed to the BigDecimal constructor is a valid number.
Ideally, you would work directly with numeric types like double or int whenever possible.

In our method, this would only require a small change to the parameter type and the parsing logic.

If you still prefer to work with String inputs, make sure the string represents a valid number format.
An example of a valid input would be:

"1337.012342

By sticking to properly formatted input, you can avoid NumberFormatException issues like the one described here.

One side note here: Proper validation of user input is a critical security measure recommended by OWASP to prevent injection vulnerabilities and ensure application robustness. Using and handling this exception may help you here depending on your use case.

Conclusion

I hope this article helped clarify what the error „Character array is missing ‚e‘ notation exponential mark“ means in Java. While today’s example was constructed for clarity, such issues often arise unexpectedly when dealing with user input or external data sources.

If you have encountered a similar error in a real-world scenario, feel free to share it in the comments. I would be happy to take a look!

If you’re interested in diving deeper into testing and automation, you might enjoy my tutorials on Selenium with Java and Selenium with Python.
Or, if you want something a little more adventurous, check out my Cucumber in Rust tutorial.

Happy testing and have a great day!

Home » Archives for Dezember 2023
Share it with:

Stable Diffusion: „LayerNormKernelImpl“ not implemented for ‚Half‘

Today I installed the Stable Diffusion Web UI by AUTOMATIC1111 on my ol‘ reliable Macbook Pro 2015 following this stable diffusion installation guide. And not only is it fun to do AI stuffs on an Intel Mac with no GPU whatsoever, of course I also had to run into a „first try error“ ™. This time it was that one:

RuntimeError: "LayerNormKernelImpl" not implemented for 'Half'

Okay, cool.

So how do we fix that?

Well it turns out that this „half“ thingy, that relates to floating point sizes, can be turned off. To do that, let’s revisit your stable-diffusion-webui installation directory and open the shell script webui-user.sh using your most beloved code editor. Here you will find the following 2 lines:

# Commandline arguments for webui.py, for example: export COMMANDLINE_ARGS="--medvram --opt-split-attention"
#export COMMANDLINE_ARGS=""

What we got to do now is: First we remove the leading ‚#‚ character of the second line to uncomment it. Next, we fill the variable with "--skip-torch-cuda-test --no-half" to make it look like this:

export COMMANDLINE_ARGS="--skip-torch-cuda-test --no-half"

Restart the stable diffusion web ui using your webui.sh and it should behave as expected. All of that has been tested with stable-diffusion-webui commit cf2772fab0af5573da775e7437e6acdca424f26e, which was the most recent stable version at the time of writing.

If you are on a Windows machine, the fix should be basically the same: Open the webui-user.bat and change COMMANDLINE_ARGS to match the following:

set COMMANDLINE_ARGS="--skip-torch-cuda-test --no-half"

Restart your server and everything should be alright. (Disclaimer: Untested due to the lack of Windows machines.)

Conclusion

So that’s all, hope this helps. If not, feel free to let me know in the comments below. If you find a better fix, or my post is outdated, or you found any other issues, please let me know as well. Let’s keep it as complete as possible for future users. And if you are still curious about working with Python apps or Python in general, here is another quick and handy post about handling environment variables. And here we talk about my second most favorite topic: Test Automation.

Best regards, and have a nice week!

Home » Archives for Dezember 2023

Share it with: