Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow use of faster floating-point number serialization (StreamWriteFeature.USE_FAST_DOUBLE_WRITER) #749

Merged
merged 24 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
<!-- 04-Mar-2019, tatu: Retain Java6/JDK1.6 compatibility for annotations for Jackson 2.x,
but use Moditect to get JDK9+ module info support; need newer bundle plugin as well
-->
<javac.src.version>1.6</javac.src.version>
<javac.target.version>1.6</javac.target.version>
<javac.src.version>1.8</javac.src.version>
<javac.target.version>1.8</javac.target.version>

<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

<osgi.export>com.fasterxml.jackson.core;version=${project.version},
com.fasterxml.jackson.core.*;version=${project.version}
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/fasterxml/jackson/core/io/NumberOutput.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.fasterxml.jackson.core.io;

import com.fasterxml.jackson.core.io.schubfach.DoubleToDecimal;
import com.fasterxml.jackson.core.io.schubfach.FloatToDecimal;

public final class NumberOutput
{
private static int MILLION = 1000000;
Expand Down Expand Up @@ -274,12 +277,12 @@ public static String toString(long v) {
}

public static String toString(double v) {
return Double.toString(v);
return DoubleToDecimal.toString(v);
}

// @since 2.6
public static String toString(float v) {
return Float.toString(v);
return FloatToDecimal.toString(v);
}

/*
Expand Down
47 changes: 47 additions & 0 deletions src/main/java/com/fasterxml/jackson/core/io/ryu/RoundingMode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

// Copyright 2018 Ulf Adams
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.fasterxml.jackson.core.io.ryu;

/**
* This is an internal class, public only for internal testing
*/
public enum RoundingMode {
CONSERVATIVE {
@Override
public boolean acceptUpperBound(boolean even) {
return false;
}

@Override
public boolean acceptLowerBound(boolean even) {
return false;
}
},
ROUND_EVEN {
@Override
public boolean acceptUpperBound(boolean even) {
return even;
}

@Override
public boolean acceptLowerBound(boolean even) {
return even;
}
};

public abstract boolean acceptUpperBound(boolean even);
public abstract boolean acceptLowerBound(boolean even);
}
Loading